iOS:即使使用 shouldAutorotateToInterfaceOrientation 也不会调用 willAnimateRotationToInterfaceOrientation

标签 ios uiwebview uitabbarcontroller orientation screen-orientation

我有

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    NSLog(@"shouldRotate");
    return YES;
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
    NSLog(@"Hello there");

    [self.webpage setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

}

但在我的日志中“hello there”从未出现,即使“shouldRotate”出现。

我的设置是让我有一个 TabBarController,里面有 4 个常规 View Controller 。特别是这个选项卡内部只有一个 WebView。当我改变方向时,什么也没有发生。

我应该在 AppDelegate 级别做些什么吗?

有人可以帮助我了解发生了什么吗?

最佳答案

如果您想使用 TabBarController 设置旋转动画,所有 Tab 栏上的 ViewController 都应返回 YES 以获得支持的方向。

shouldAutorotateToInterfaceOrientation 只是一个地方,您可以在其中配置此设置。

关于iOS:即使使用 shouldAutorotateToInterfaceOrientation 也不会调用 willAnimateRotationToInterfaceOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7955910/

相关文章:

iphone - 在 iPhone 5 上使用 EGOPhotoViewController

ios - MPMoviePlayerController 隐藏音量 slider

ios - 如何在 WKWebview 上禁用 goBack 和 goForward

ios - 当前模型关闭时间时快速传递数组值

objective-c - 默认标签栏 View ?

ios - 重用 UITableViewCell 时缺少 subview

ios - Telegram iOS 应用程序无法使用 Xcode 6.1.1 构建

ios - 如何检测 UIWebView 上的 DOM 加载事件?

ios - UIWebView IBOutlet 连接问题

swift - 如何快速更改标签栏的色调颜色?