钥匙窗口不旋转
我有一个带有导航栏的 UIViewTable。当我读取数据时,我会在表格顶部显示带有 ActivityIndicator 的 UIViewController 。问题是当我旋转设备时,此顶视图没有旋转,我不知道为什么? :( 这是我使用 ActivityIndicator 添加顶视图的方法:
UIView *view = [[UIApplication sharedApplication] keyWindow];
[view addSubview:viewWithLoader.view];
这是我删除它的方法:
[viewWithLoader.view removeFromSuperview];
这是顶视图中的方法(使用 ActivityIndicator):
- (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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调用 [self.window makeKeyAndVisible] 后;在您的应用程序委托上,获得旋转通知、动画等的视图是该初始视图的子视图。
我碰巧有一个顶栏取代了状态栏。所以我认为将其实际添加为关键窗口的子视图是一个好主意。但正是这种情况导致了你所经历的结果。
您有两个选择
无论谁拥有该顶视图都应该负责旋转它或在旋转发生时删除/添加它,以便它具有正确的方向。
无论
使该顶视图成为自动旋转的视图之一的子视图。
两者都很容易实现,但我发现不行。 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
whoever owns that topview should take care of rotating it or remove/add it when a rotation occurs so it has the right orientation.
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.
我找到了解决方案:)我将这个顶视图(带有加载程序)添加为“模态视图”,并且旋转在所有视图中都可以正常工作:)
I found solution :) I add this top view (with loader) as 'modal view' and rotation works fine in all views :)