简体   繁体   English

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

[英]willAnimateSecondHalfOfRotationFromInterfaceOrientation not called in root view controller

I have created the one rootviewcontroller , and then make that geosensitive by writing 我创建了一个rootviewcontroller,然后通过编写使其具有地理敏感性

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return YES;
}

In rootviewcontroller willAnimateSecondHalfOfRotationFromInterfaceOrientation method is called and images are resizing. 在rootviewcontroller中调用willAnimateSecondHalfOfRotationFromInterfaceOrientation方法并调整图像大小。

I also have some views on it, but when I rotate the screen the view will be rotate but the images are not resizing though I have used the same 我也有一些观点,但当我旋转屏幕时,视图将旋转,但图像没有调整大小,虽然我使用了相同的

-(void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration
{
    UIInterfaceOrientation toOrientation = self.interfaceOrientation;
}

method but it cannot called. 方法,但它无法调用。 So, what can I do? 那么,我该怎么办? Please help me. 请帮我。

This got me too. 这也让我受益匪浅。 I think you'll find the answer if you look at that header file for UIViewController. 如果你看一下UIViewController的头文件,我想你会找到答案。 There are comments in there which state that you may override EITHER 在那里有评论声明您可以覆盖EITHER

  • (void)willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration: (void)willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:

OR any of the following 以下任何一项

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

Apparently if you override the first one, that's the only one that will be called. 显然,如果你覆盖第一个,那是唯一一个将被调用的。 If you want feedback from each stage of the rotation, use any of the ones in the 2nd set, but LEAVE OUT the first one. 如果您想要从旋转的每个阶段获得反馈,请使用第二组中的任何一个,但是将第一组中的任何一个移出。

Another thing to consider is that you have overridden shouldAutorotateToInterfaceOrientation method to allow rotations other then the default of portrait. 另一件需要考虑的事情是你已经覆盖了shouldAutorotateToInterfaceOrientation方法,以允许旋转除了默认的肖像。

For example : 例如 :

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return YES;
}

If you don't do this, your implementated methods won't be called. 如果不这样做,则不会调用实现的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM