When my interface rotates i want to call certain functions. How can I do the开发者_开发知识库se actions?
Depending on what you want to do,
Implement some of these methods in your active view controller class:
-willRotateToInterfaceOrientation:duration:
-willAnimateRotationToInterfaceOrientation:duration:
-didRotateFromInterfaceOrientation:
Or some of these methods in your app delegate:
-application:willChangeStatusBarOrientation:duration:
-application:didChangeStatusBarOrientation:
Or listen to some of these local notifications:
- UIApplicationWillChangeStatusBarFrameNotification
- UIApplicationDidChangeStatusBarFrameNotification
- UIApplicationWillChangeStatusBarOrientationNotification
- UIApplicationDidChangeStatusBarOrientationNotification
You can use this:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yourMethod:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
精彩评论