钥匙窗口不旋转

发布于 2024-10-23 13:56:23 字数 554 浏览 3 评论 0原文

我有一个带有导航栏的 UIViewTable。当我读取数据时,我会在表格顶部显示带有 ActivityIndi​​cator 的 UIViewController 。问题是当我旋转设备时,此顶视图没有旋转,我不知道为什么? :( 这是我使用 ActivityIndi​​cator 添加顶视图的方法:

UIView *view = [[UIApplication sharedApplication] keyWindow];
[view addSubview:viewWithLoader.view];

这是我删除它的方法:

[viewWithLoader.view removeFromSuperview];

这是顶视图中的方法(使用 ActivityIndi​​cator):

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

I have a UIViewTable with navigation bar. When I read data I display UIViewController with ActivityIndicator on top of the table. The problem is when I rotate device this top view is not rotating, I don't know why? :(
This is how I add top view with ActivityIndicator:

UIView *view = [[UIApplication sharedApplication] keyWindow];
[view addSubview:viewWithLoader.view];

This is how I remove it:

[viewWithLoader.view removeFromSuperview];

This is method from top view (with ActivityIndicator):

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

定格我的天空 2024-10-30 13:56:23

调用 [self.window makeKeyAndVisible] 后;在您的应用程序委托上,获得旋转通知、动画等的视图是该初始视图的子视图。

我碰巧有一个顶栏取代了状态栏。所以我认为将其实际添加为关键窗口的子视图是一个好主意。但正是这种情况导致了你所经历的结果。

您有两个选择

  1. 无论谁拥有该顶视图都应该负责旋转它或在旋转发生时删除/添加它,以便它具有正确的方向。

    无论

  2. 使该顶视图成为自动旋转的视图之一的子视图。

两者都很容易实现,但我发现不行。 2对于用户来说在视觉上更有吸引力。

after you call [self.window makeKeyAndVisible]; on your App delegate, the views that get the rotation notification, animation, etc, etc. are the subviews of that initial view.

It happen to me that I had a top bar that replaced the status bar. so I thought it will be a good idea to actually add it as a sub view of the key window. But that being the case resulted in the outcome you are experiencing.

You have 2 options

  1. whoever owns that topview should take care of rotating it or remove/add it when a rotation occurs so it has the right orientation.

  2. make that topview a subview of one of the views that ARE autorotating.

Both are really easy to implement but I found no. 2 is more visually attractive for the user.

别靠近我心 2024-10-30 13:56:23

我找到了解决方案:)我将这个顶视图(带有加载程序)添加为“模态视图”,并且旋转在所有视图中都可以正常工作:)

...
[self presentModalViewController:ldr animated:YES];
...
[self dismissModalViewControllerAnimated:YES];

I found solution :) I add this top view (with loader) as 'modal view' and rotation works fine in all views :)

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