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

发布于 2024-12-12 21:39:56 字数 686 浏览 5 评论 0原文

我有

- (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神也荒唐 2024-12-19 21:39:56

如果您想使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文