iPhone UIActionSheet 自动旋转不起作用
我读了很多相关内容。人们说,当其父级未设置为自动旋转时,它不会自动旋转。我尝试了一切但没有运气。 我创建了基于视图的应用程序(v4.2),并带有一个执行此操作的按钮:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button" otherButtonTitles:@"Other Button 1", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet showInView:self.view];
根控制器设置为自动旋转。而actionSheet则没有。请注意,当我旋转模拟器时,不会调用根控制器的任何方向方法。代表有问题吗?怎么了?
I read a lot about that. People say it will not autorotate whene its parent is not set to auto rotate. I tried everything but no luck.
I created view-based app (v4.2) with a button that executes this:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive Button" otherButtonTitles:@"Other Button 1", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet showInView:self.view];
The root controller is set to auto-rotate. The actionSheet does not. Note that when I rotate the simulator none of the root controller's orientation methods are called. Is there a problem with the delegate? What is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,这是我对这个问题的解决方案:
基本上我们所做的是:
例如:
Well, here's my solution to this problem:
Basically what we do is:
for example:
我发现当我从从属视图(我使用导航控制器推送的)的委托方法中呈现操作表时遇到了这个问题。问题是我的视图不是当前的视图,从属视图仍然在我试图显示操作表的位置。
通过稍微更改我的代码,以便委托方法记录所需与用户的交互,并将操作表呈现推迟到该视图的 viewDidAppear 方法,该表在逻辑界面动画中的适当时间出现,并且自动旋转问题消失了。您可能想看看这是否对您有帮助。
换句话说,流程变成:
I found that I was running into this problem when I was presenting the action sheet in a delegate method from a subordinate view (which I had pushed using the navigation controller). The problem was that my view was not the current one, the subordinate view was still up at the point where I was trying to show the action sheet.
By changing my code a little bit so that the delegate method made a note of the interaction needed with the user, and deferring the action sheet presentation to this view’s viewDidAppear method, the sheet appeared at the proper time in the logical interface animation, and the auto-rotation problem went away. You might want to see if that helps you.
In other words, the flow became: