如何在iPhone旋转90度时触发功能?

joh*_*ohn 5 iphone

如何检测iPhone的旋转大约90度?此外,我不需要/希望屏幕本身旋转.我只是想在手机旋转时调用一个功能.谢谢!

Lou*_*nco 8

您的视图控制器将被发送:

  -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
Run Code Online (Sandbox Code Playgroud)

实现它以在手机旋转时执行某些操作

轮换完成后,您将获得:

  - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
Run Code Online (Sandbox Code Playgroud)

这是在文档中(请参阅处理视图旋转)

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html