Hi I don't understand how to intercept if the user rotate the phone in from portarait to landscape or from landscape to portrait. I know that there are few methods:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInte开发者_如何学运维rfaceOrientation)interfaceOrientation
but If I put this method in AppDelegate.
Anyone can help me?
Those are not UIApplicationDelegate
methods, so your AppDelegate won't receive them.
They're implemented in UIViewController
and you can override them in one of your view controllers (subclasses of UIViewController
)
You need to implement these delegate methods into your viewcontroller then whenever your view controller rotates. You will get response in respective delegtes.
You can use this in any or all of the view controllers that u are using. That will intercept the change for that particular view controller. Those are UIViewController
delegates and are not accessible by appDelegate
Andrea you can implement those methods in your viewcontroller and your view controller is responsible to call those delegate methods
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationPortrait) {}
else {}
}
精彩评论