在根视图控制器中未调用willAnimateSecondHalfOfRotationFromInterfaceOrientation

4 iphone objective-c

我创建了一个rootviewcontroller,然后通过编写使其具有地理敏感性

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

在rootviewcontroller willAnimateSecondHalfOfRotationFromInterfaceOrientation中调用方法并调整图像大小.

我也有一些观点,但当我旋转屏幕时,视图将旋转,但图像没有调整大小,虽然我使用了相同的

-(void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration
{
    UIInterfaceOrientation toOrientation = self.interfaceOrientation;
}
Run Code Online (Sandbox Code Playgroud)

方法,但它无法调用.那么,我该怎么办?请帮我.

Cru*_*inh 5

这也让我受益匪浅.如果你看一下UIViewController的头文件,我想你会找到答案.在那里有评论声明您可以覆盖EITHER

  • (void)willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:

以下任何一项

  • (空隙)willAnimateFirstHalfOfRotationToInterfaceOrientation:持续时间:
  • (空隙)didAnimateFirstHalfOfRotationToInterfaceOrientation:
  • (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:

显然,如果你覆盖第一个,那是唯一一个将被调用的.如果您想要从旋转的每个阶段获得反馈,请使用第二组中的任何一个,但是将第一组中的任何一个移出.