我如何检测iPhone的旋转大约90度?此外,我不需要/不想让屏幕本身旋转。我只想在手机旋转时调用一个函数。谢谢!
你的视图控制器将被发送:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
当手机旋转时,实现它以执行某些操作。
旋转完成后,您将得到:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
这里是文档中的相关内容(参见处理视图旋转)。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
您需要捕获在视图控制器旋转之前发送的事件。具体来说:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
和后旋转
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
你应该先实现实例方法 "shouldAutorotateToInterfaceOrientation" 并返回 YES。 然后这两个方法将被调用。
方法名称是正确的...但它们从未被调用过。这是什么原因呢?