iOS:即使使用 shouldAutorotateToInterfaceOrientation 也不会调用 willAnimateRotationToInterfaceOrientation
我有
- (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 个常规视图控制器。特别是这个选项卡里面只有一个 WebView。当我改变方向时,什么也没有发生。
我应该在 AppDelegate 级别做一些事情吗?
有人可以帮助我了解发生了什么事吗?
I have
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLog(@"shouldRotate");
return YES;
}
and
- (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)];
}
But in my log "hello there" never appears, even though "shouldRotate" does.
My setup is so that I have a TabBarController with 4 regular View Controllers inside of them. This tab in particular just has a WebView inside of it. When I shift the orientation simply nothing happens.
Should I be doing something at the AppDelegate level?
Could someone help me understand whats going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想使用 TabBarController 实现旋转动画,则所有选项卡栏上的 ViewController 都应返回 YES 以支持方向。
shouldAutorotateToInterfaceOrientation 就是您可以配置此设置的地方。
If you want to animate rotation with TabBarController, ViewControllers on all Tab bars should return YES for supported orientation.
shouldAutorotateToInterfaceOrientation is just place, where you can configure this setting.