Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TDSemiModalViewController now supports instantiation in all interface…

… orientations.

NOTE: auto-rotate is still not working i.e. if the device gets rotated while the semi-modal dialog is shown, it won't rotate itself
  • Loading branch information...
commit 1c02006b3aec123d491fd76dfacd276235b0997f 1 parent 7d227fa
@ishaq ishaq authored
View
6 Demo/Classes/TDSemiModalDemoViewController.m
@@ -22,6 +22,12 @@ - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
+// Override to allow orientations other than the default portrait orientation.
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ // Return YES for supported orientations
+ return YES;
+}
+
- (void)viewDidUnload {
}
View
9 Demo/TDSemiModal.xcodeproj/project.pbxproj
@@ -168,7 +168,6 @@
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "TDSemiModal" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
@@ -250,10 +249,12 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.0;
PREBINDING = NO;
- SDKROOT = iphoneos4.1;
+ SDKROOT = iphoneos4.0;
};
name = Debug;
};
@@ -263,11 +264,13 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 3.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
PREBINDING = NO;
- SDKROOT = iphoneos4.1;
+ SDKROOT = iphoneos4.0;
};
name = Release;
};
View
198 Demo/TDSemiModalDemoViewController.xib
@@ -3,12 +3,12 @@
<data>
<int key="IBDocument.SystemTarget">1024</int>
<string key="IBDocument.SystemVersion">10F569</string>
- <string key="IBDocument.InterfaceBuilderVersion">804</string>
+ <string key="IBDocument.InterfaceBuilderVersion">788</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">123</string>
+ <string key="NS.object.0">117</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -44,7 +44,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIButton" id="677004754">
<reference key="NSNextResponder" ref="774585933"/>
- <int key="NSvFlags">292</int>
+ <int key="NSvFlags">301</int>
<string key="NSFrame">{{52, 53}, {213, 37}}</string>
<reference key="NSSuperview" ref="774585933"/>
<bool key="IBUIOpaque">NO</bool>
@@ -351,196 +351,6 @@
</object>
</object>
</object>
- <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSError.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIAccessibility.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UINibLoading.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier" id="385688474">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIResponder.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIButton</string>
- <string key="superclassName">UIControl</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIButton.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIControl</string>
- <string key="superclassName">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIControl.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIDatePicker</string>
- <string key="superclassName">UIControl</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIDatePicker.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIResponder</string>
- <string key="superclassName">NSObject</string>
- <reference key="sourceIdentifier" ref="385688474"/>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UISearchBar</string>
- <string key="superclassName">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UISearchBar.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UISearchDisplayController</string>
- <string key="superclassName">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UISearchDisplayController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIView</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UITextField.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIView</string>
- <string key="superclassName">UIResponder</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UINavigationController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIPopoverController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UISplitViewController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UITabBarController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">UIViewController</string>
- <string key="superclassName">UIResponder</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">UIKit.framework/Headers/UIViewController.h</string>
- </object>
- </object>
- </object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
@@ -555,6 +365,6 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">TDSemiModal.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
- <string key="IBCocoaTouchPluginVersion">123</string>
+ <string key="IBCocoaTouchPluginVersion">117</string>
</data>
</archive>
View
6 Source/TDDatePickerController.m
@@ -17,6 +17,12 @@ -(void)viewDidLoad {
datePicker.date = [NSDate date];
}
+// Override to allow orientations other than the default portrait orientation.
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ // Return YES for supported orientations
+ return YES;
+}
+
#pragma mark -
#pragma mark Actions
View
80 Source/TDDatePickerController.xib
@@ -3,12 +3,12 @@
<data>
<int key="IBDocument.SystemTarget">1024</int>
<string key="IBDocument.SystemVersion">10F569</string>
- <string key="IBDocument.InterfaceBuilderVersion">804</string>
+ <string key="IBDocument.InterfaceBuilderVersion">788</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="NS.object.0">123</string>
+ <string key="NS.object.0">117</string>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -44,8 +44,8 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIDatePicker" id="324506899">
<reference key="NSNextResponder" ref="299927514"/>
- <int key="NSvFlags">290</int>
- <string key="NSFrame">{{0, 244}, {320, 216}}</string>
+ <int key="NSvFlags">266</int>
+ <string key="NSFrame">{{0, 244}, {460, 216}}</string>
<reference key="NSSuperview" ref="299927514"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
@@ -263,7 +263,7 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA</b
<string>UIResponder</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string>{{790, 233}, {320, 460}}</string>
+ <string>{{521, 231}, {320, 460}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAAAAAAAAw+UAAA</bytes>
@@ -300,56 +300,14 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA</b
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">Classes/SimpleURL.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">Classes/TodoistAPI.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">JSON/NSObject+SBJSON.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">JSON/SBJsonWriter.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">LoginViewController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier" id="572837301">
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="649895216">
<string key="majorKey">IBProjectSource</string>
- <string key="minorKey">TDDatePickerController.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">TaskDetailsViewController.h</string>
+ <string key="minorKey">../Source/TDDatePickerController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">TDDatePickerController</string>
- <string key="superclassName">UIViewController</string>
+ <string key="superclassName">TDSemiModalViewController</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
@@ -421,13 +379,21 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA</b
</object>
</object>
</object>
- <reference key="sourceIdentifier" ref="572837301"/>
+ <reference key="sourceIdentifier" ref="649895216"/>
</object>
<object class="IBPartialClassDescription">
- <string key="className">UIView</string>
+ <string key="className">TDSemiModalViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">../Source/TDSemiModalViewController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">UIViewController</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
- <string key="minorKey">JSON/TDUtils.h</string>
+ <string key="minorKey">../Source/UIViewController+TDSemiModalExtension.h</string>
</object>
</object>
</object>
@@ -519,7 +485,7 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA</b
</object>
<object class="IBPartialClassDescription">
<string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier" id="577619403">
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="965120043">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">UIKit.framework/Headers/UIResponder.h</string>
</object>
@@ -559,7 +525,7 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA</b
<object class="IBPartialClassDescription">
<string key="className">UIResponder</string>
<string key="superclassName">NSObject</string>
- <reference key="sourceIdentifier" ref="577619403"/>
+ <reference key="sourceIdentifier" ref="965120043"/>
</object>
<object class="IBPartialClassDescription">
<string key="className">UISearchBar</string>
@@ -649,8 +615,8 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA</b
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
- <string key="IBDocument.LastKnownRelativeProjectPath">Todoist.xcodeproj</string>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../Demo/TDSemiModal.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
- <string key="IBCocoaTouchPluginVersion">123</string>
+ <string key="IBCocoaTouchPluginVersion">117</string>
</data>
</archive>
View
3  Source/TDSemiModalViewController.m
@@ -14,7 +14,8 @@ @implementation TDSemiModalViewController
-(void)viewDidLoad {
[super viewDidLoad];
- self.coverView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
+ //self.coverView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
+ self.coverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
self.coverView.backgroundColor = UIColor.blackColor;
}
View
73 Source/UIViewController+TDSemiModalExtension.m
@@ -11,31 +11,61 @@
@implementation UIViewController (TDSemiModalExtension)
// Use this to show the modal view (pops-up from the bottom)
-- (void) presentSemiModalViewController:(TDSemiModalViewController*)vc {
+- (void) presentSemiModalViewController:(TDSemiModalViewController*)vc {
+#define DEGREES_TO_RADIANS(x) (M_PI * (x)/180.0)
+
UIView* modalView = vc.view;
UIView* coverView = vc.coverView;
-
+
UIWindow* mainWindow = [(id)[[UIApplication sharedApplication] delegate] window];
CGPoint middleCenter = self.view.center;
CGSize offSize = [UIScreen mainScreen].bounds.size;
- CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.2);
-
+
+ UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
+
+ CGPoint offScreenCenter = CGPointZero;
+
+ if(orientation == UIInterfaceOrientationPortraitUpsideDown) {
+ offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * -1.2);
+ [modalView setTransform:CGAffineTransformIdentity];
+ [modalView setTransform:CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(180))];
+ [modalView setBounds:CGRectMake(0, 0, 320, 460)];
+ }
+ else if(orientation == UIInterfaceOrientationLandscapeLeft) {
+ offScreenCenter = CGPointMake(offSize.width * 1.2, offSize.height / 2);
+ [modalView setTransform:CGAffineTransformIdentity];
+ [modalView setTransform:CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-90))];
+ [modalView setBounds:CGRectMake(0, 0, 480, 300)];
+ }
+ else if(orientation == UIInterfaceOrientationLandscapeRight) {
+ offScreenCenter = CGPointMake(offSize.width * -1.2, offSize.height / 2);
+ [modalView setTransform:CGAffineTransformIdentity];
+ [modalView setTransform:CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90))];
+ [modalView setBounds:CGRectMake(0, 0, 480, 300)];
+ }
+ else { // assume portrait
+ offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.2);
+ [modalView setTransform:CGAffineTransformIdentity];
+ [modalView setTransform:CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(0))];
+ [modalView setBounds:CGRectMake(0, 0, 320, 460)];
+ }
+
+
modalView.center = offScreenCenter;
coverView.alpha = 0.5;
-
// we start off-screen
[mainWindow addSubview:coverView];
[mainWindow addSubview:modalView];
-
+
// Show it with a transition effect
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.6];
-
+
modalView.center = middleCenter;
//coverView.alpha = 0.5;
-
+
[UIView commitAnimations];
-
+
}
// Use this to slide the semi-modal view back down.
@@ -43,17 +73,34 @@ -(void) dismissSemiModalViewController:(TDSemiModalViewController*)vc {
double animationDelay = 0.7;
UIView* modalView = vc.view;
UIView* coverView = vc.coverView;
-
+
CGSize offSize = [UIScreen mainScreen].bounds.size;
- CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);
-
+
+ UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
+
+ CGPoint offScreenCenter = CGPointZero;
+
+ if(orientation == UIInterfaceOrientationPortraitUpsideDown) {
+ offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * -1.5);
+ }
+ else if(orientation == UIInterfaceOrientationLandscapeLeft) {
+ offScreenCenter = CGPointMake(offSize.width * 1.5, offSize.height / 2);
+ }
+ else if(orientation == UIInterfaceOrientationLandscapeRight) {
+ offScreenCenter = CGPointMake(offSize.width * -1.5, offSize.height / 2);
+ }
+ else { // assume portrait
+ offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);
+ }
+
+
[UIView beginAnimations:nil context:modalView];
[UIView setAnimationDuration:animationDelay];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(dismissSemiModalViewControllerEnded:finished:context:)];
modalView.center = offScreenCenter;
[UIView commitAnimations];
-
+
[coverView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:animationDelay];
}
Please sign in to comment.
Something went wrong with that request. Please try again.