Bri*_*ang 32
取决于你想要做出反应:
如果在旋转之前,从UIViewController 覆盖:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// do something before rotation
}
Run Code Online (Sandbox Code Playgroud)
如果你想在轮换后执行某些操作:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
// do something after rotation
}
Run Code Online (Sandbox Code Playgroud)
参考:
UIDevice
帖子 UIDeviceOrientationDidChangeNotification
UIApplication
帖子UIApplicationWillChangeStatusBarOrientationNotification
和UIApplicationDidChangeStatusBarOrientationNotification
并且每个都有一个相关的委托回调.
UIViewController
如果视图控制器是由窗口管理的控制器层次结构的一部分,则接收由UIDevice通知触发的多个与方向相关的调用.
如果您已经在使用UIViewController,请实现一些与方向相关的方法,否则请注册UIDevice通知.最重要的UIViewController方法是shouldAutorotateToInterfaceOrientation
因为如果返回NO
其他人则不会被调用.
归档时间: |
|
查看次数: |
17620 次 |
最近记录: |