2009-06-22 58 views

回答

8

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

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 

实现它做一些事情的时候,手机被旋转

转动完成后,您将获得:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 

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

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

1

当您旋转设备时,您的视图控制器会收到一个didRotateFromInterfaceOrientation: 消息,其中旧方向。您可以检查interfaceOrientation属性以查看当前的旋转,并相应地执行操作。

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
1

您需要捕获在ViewController旋转之前发送的事件。即:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 

和岗位轮换

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
0

方法名是正确的......但他们从来没有被调用。 会导致什么?

1

你应该先实现实例方法“shouldAutorotateToInterfaceOrientation”并返回YES。 然后这两个方法将被调用。