当我的界面旋转时,我想调用某些功能。我该怎么做?
答案 0 :(得分:9)
取决于您想要做什么,
在您的活动视图控制器类中实现some of these methods:
-willRotateToInterfaceOrientation:duration:
-willAnimateRotationToInterfaceOrientation:duration:
-didRotateFromInterfaceOrientation:
或者您的app委托中的some of these methods:
-application:willChangeStatusBarOrientation:duration:
-application:didChangeStatusBarOrientation:
或听取some of these local notifications:
答案 1 :(得分:5)
您可以使用:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yourMethod:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];