我有
- (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/