-
-
Save epologee/b8670e5976635a629842 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface AbstractViewController : UIViewController | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AbstractViewController.h" | |
@implementation AbstractViewController | |
- (void)loadView { | |
self.view = [[[UIView alloc] init] autorelease]; | |
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(50, 10, 200, 50)] autorelease]; | |
label.numberOfLines = 2; | |
label.text = [[[self class] description] stringByAppendingFormat:@"\nAccept landscape: %@", [self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft] ? @"YES" : @"NO"]; | |
[self.view addSubview:label]; | |
} | |
-(void)viewWillAppear:(BOOL)animated { | |
NSLog(@"%@ appeared with app frame %@ vs self.frame %@", [[self class] description], NSStringFromCGRect([[UIScreen mainScreen] applicationFrame]), NSStringFromCGRect(self.view.frame)); | |
} | |
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { | |
DLog(@"%@ from %i", self, fromInterfaceOrientation); | |
} | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | |
return (interfaceOrientation == UIInterfaceOrientationPortrait); | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface DeviceRotationAppDelegate : NSObject <UIApplicationDelegate> | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "DeviceRotationAppDelegate.h" | |
#import "FirstViewController.h" | |
@interface DeviceRotationAppDelegate () | |
@property (nonatomic, retain) UINavigationController *navigationController; | |
@property (nonatomic, retain) UIWindow *window; | |
@end | |
@implementation DeviceRotationAppDelegate | |
@synthesize window=_window, navigationController; | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
self.window.backgroundColor = [UIColor whiteColor]; | |
FirstViewController *fvc = [[[FirstViewController alloc] init] autorelease]; | |
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:fvc] autorelease]; | |
self.navigationController.navigationBarHidden = YES; | |
[self.window addSubview:self.navigationController.view]; | |
[self.window makeKeyAndVisible]; | |
return YES; | |
} | |
- (void)dealloc { | |
self.navigationController = nil; | |
self.window = nil; | |
[super dealloc]; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import "AbstractViewController.h" | |
@interface FirstViewController : AbstractViewController | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "FirstViewController.h" | |
#import "SecondViewController.h" | |
@implementation FirstViewController | |
-(void)loadView { | |
[super loadView]; | |
UIView *nextButton = [[[UIView alloc] initWithFrame:CGRectMake(10, 40, 25, 25)] autorelease]; | |
nextButton.backgroundColor = [UIColor orangeColor]; | |
[nextButton addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushNext)] autorelease]]; | |
[self.view addSubview:nextButton]; | |
} | |
-(void)pushNext { | |
[self.navigationController pushViewController:[[[SecondViewController alloc] init] autorelease] animated:YES]; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import "AbstractViewController.h" | |
@interface SecondViewController : AbstractViewController | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "SecondViewController.h" | |
#import "ThirdViewController.h" | |
@implementation SecondViewController | |
-(void)loadView { | |
[super loadView]; | |
UIView *previousButton = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 25, 25)] autorelease]; | |
previousButton.backgroundColor = [UIColor orangeColor]; | |
[previousButton addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(popBack)] autorelease]]; | |
[self.view addSubview:previousButton]; | |
UIView *nextButton = [[[UIView alloc] initWithFrame:CGRectMake(10, 40, 25, 25)] autorelease]; | |
nextButton.backgroundColor = [UIColor blueColor]; | |
[nextButton addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pushNext)] autorelease]]; | |
[self.view addSubview:nextButton]; | |
} | |
-(void)pushNext { | |
[self.navigationController pushViewController:[[[ThirdViewController alloc] init] autorelease] animated:YES]; | |
} | |
-(void)popBack { | |
[self.navigationController popViewControllerAnimated:YES]; | |
} | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | |
return YES; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import "AbstractViewController.h" | |
@interface ThirdViewController : AbstractViewController | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ThirdViewController.h" | |
@implementation ThirdViewController | |
-(void)loadView { | |
[super loadView]; | |
UIView *previousButton = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 25, 25)] autorelease]; | |
previousButton.backgroundColor = [UIColor blueColor]; | |
[previousButton addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(popBack)] autorelease]]; | |
[self.view addSubview:previousButton]; | |
} | |
-(void)popBack { | |
[self.navigationController popViewControllerAnimated:YES]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment