i have a simple structure for IPAD with an AppDelegate that include a view from a viewController :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ClockVC *clockVC = [[ClockVC alloc]init];
clockVC.view.frame = CGRectMake(100, 100, clockVC.view.bounds.size.width, clockVC.view.bounds.size.height);
[self.window addSubview:clockVC.view];
[self.window makeKeyAndVisible];
return YES;
}
clockVC has a viewDidLoad defined by this code :
- (void)viewDidLoad {
[super viewDidLoad];
self.view.autoresizingMask = UIViewAutoresizingNone;
self.view.autoresizesSubviews = UIViewAutoresizingNone;
}
Bounds of clockVC are defined by IB and override in application:didFinishLaunching... Width and Height are respectively 200 and 150.
ClockVC implements method for one-step auto-rotation : /
/ Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[UIView animateWithDuration:0.5
animations:^{self.view.alpha = 0;}
];
}
-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[UIView animateWithDuration:1
animations:^{self.view.alpha = 1;}
];
}
At the first load the page is correctly viewed and clockVC view is in position. When i rotate clockVC view (whose autoResizeMask is set to UIViewAutoresizingNon)resize to take the entire screen.
Why ?? i'd like to mantain initial size.
Here screenshots of my problem. Before rotation:
After Rotation: