模态视图控制器出现在操作表后面
我的模态视图控制器显示在 UIActionSheet 后面,并且我的 UIActionSheet 不会被忽略。我正在使用:
[self presentModalViewController:composeTweetView animated:YES];
展示我的模态视图控制器。
我的操作表从 tabBar 显示:
[actionSheet showFromTabBar:self.parentViewController.tabBarController.tabBar];
此代码适用于 iOS 4.0。
if (buttonIndex == 0) {
if (self.isLoggedIn) {
[FlurryAPI logEvent:@"ST_REPLY_CLICKED"];
composeTweetView.isDirectMessage = FALSE;
[self presentModalViewController:composeTweetView animated:YES];
[composeTweetView release];
}
else {
LoginViewController* loginView = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
loginView.delegate = self;
loginView.isPostingComment = TRUE;
self.isReply = TRUE;
[self presentModalViewController:loginView animated:YES];
[loginView release];
[composeTweetView release];
}
}
摘要:
我有一个包含 UITabBar 的 UIViewController。我正在呈现一个 UIActionSheet,其中有一些呈现模式视图控制器的按钮。当模态视图控制器出现时,UIActionSheet 应该自行消失,并且模态视图应该位于堆栈的顶部。问题是,UIActionSheet 不会关闭,模态视图会在其后面加载。这个问题直到iOS 4.2.1才出现
重现步骤:
- 创建一个TabBar项目,设置 iOS 4.2.1 的基础 SDK
- 创建一个按钮或触发器来显示 UIActionSheet
- 允许 UIActionSheet 中的按钮之一使用以下语法呈现模式视图控制器:
[actionSheet showFromTabBar:self.parentViewController.tabBarController.tabBar] ;
预期结果:
1. The UIActionSheet should dismiss itself, and the modal view should appear in front
实际结果:
1. The UIActionSheet does not get dismissed and the modal view appears behind it.
回归:
This problem was not apparent prior to iOS 4.2.1
注释: 我尝试了其他显示 UIActionSheet 的方法,但所有这些方法都无法按预期工作:
//[actionSheet showInView:self.parentViewController.tabBarController.tabBar];
//[actionSheet showInView:[self.view window]];
//[actionSheet showInView:self.parentViewController.tabBarController.view];
//[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
My modal view controllers are being shown behind my UIActionSheet, and my UIActionSheet is not getting dismissed. I am using:
[self presentModalViewController:composeTweetView animated:YES];
To present my modal view controller.
My action sheet is being shown from the tabBar:
[actionSheet showFromTabBar:self.parentViewController.tabBarController.tabBar];
This code worked on iOS 4.0.
if (buttonIndex == 0) {
if (self.isLoggedIn) {
[FlurryAPI logEvent:@"ST_REPLY_CLICKED"];
composeTweetView.isDirectMessage = FALSE;
[self presentModalViewController:composeTweetView animated:YES];
[composeTweetView release];
}
else {
LoginViewController* loginView = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
loginView.delegate = self;
loginView.isPostingComment = TRUE;
self.isReply = TRUE;
[self presentModalViewController:loginView animated:YES];
[loginView release];
[composeTweetView release];
}
}
Summary:
I have a UIViewController that contains a UITabBar. I am presenting a UIActionSheet which has a few buttons that present a modal view controller. When the modal view controller is presented, the UIActionSheet should dismiss itself and the modal view should be on the top of the stack. The problem is, the UIActionSheet does not dismiss, and the modal view is loaded behind it. This problem did not occur up until iOS 4.2.1
Steps to Reproduce:
- Create a TabBar project, setting
your Base SDK to iOS 4.2.1 - Create a button or trigger to show a UIActionSheet
- Allow one of the buttons in the UIActionSheet to present a modal view controller using the syntax:
[actionSheet showFromTabBar:self.parentViewController.tabBarController.tabBar];
Expected Results:
1. The UIActionSheet should dismiss itself, and the modal view should appear in front
Actual Results:
1. The UIActionSheet does not get dismissed and the modal view appears behind it.
Regression:
This problem was not apparent prior to iOS 4.2.1
Notes:
I have tried other ways of displaying the UIActionSheet all of which don't work as intended:
//[actionSheet showInView:self.parentViewController.tabBarController.tabBar];
//[actionSheet showInView:[self.view window]];
//[actionSheet showInView:self.parentViewController.tabBarController.view];
//[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
在整理一个示例以重现您的问题时,我查看了 UIActionSheet 委托方法。我相信您可以使用:
而不是
我没有测试过它,但我相信您仍然会得到相同的按钮编号,并且直到操作表从视图中消失之前它不会触发。
In putting together a sample in order to reproduce your problem I took a look at the UIActionSheet delegate methods. I believe you can use:
instead of
I haven't tested it, but I believe you still get the same button number and it doesn't fire until the actionsheet has disappeared from the view.
抱歉,我不明白你的问题,但一切对我来说都很好。我已在模拟器中尝试了以下代码,并在 4.2.1 iPod Touch 4G(均有效)上
IBAction
连接(必须将 < code>FileOwner 到FirstViewController
)FirstViewController.h
中设置委托方法(
)/ /编辑:好的,我看到你想以模态方式呈现它,但即使这对我在 4.2.1 上也有效,
也许它有效,因为我使用
self.tabBarController.tabBar
,尝试一下I don't understand your problem sorry but everything works great for me. I have tried the following code in Simulator and on 4.2.1 iPod Touch 4G (both worked)
IBAction
(have to name theFileOwner
toFirstViewController
)FirstViewController.h
(<UIActionSheetDelegate>
)//EDIT: ok I saw that you want to present it modally but even this works for me on 4.2.1
maybe it works because I use
self.tabBarController.tabBar
, try that不确定您是否已经解决了这个问题。但我在上面没有看到明确的答案。我遇到了和你完全相同的问题。所以最后,这是我这边的一个问题,但帮助我调试这个问题的是
按照 Matthew 的建议在方法中添加实际的操作代码。
这证明这个观点实际上被驳回了。就在那时,我意识到我将 UIActionSheet alloc 放入了 viewWillAppear 方法中。因此,每次出现视图时,它都会重新创建操作表。
Not sure if you have already resolved this. But I didn't see a clear answer above. I was having exactly the same problem as you. So in the end, it was an issue on my side, but what help me debug this was to add the actual action code in the method
as suggested by Matthew.
This proved that the view was actually dismissed. That's when I realized that I put the UIActionSheet alloc in my viewWillAppear method. So each time the view appears it re-creates the action sheet.
这看起来很奇怪,正如 SDK 文档所述:
我可以想到它可能不会消失的 3 种可能性:
This seems weird as the SDK Documentation states:
I can think of 3 possibilities why it may not disappear:
我刚刚编写了一个快速示例应用程序来测试这一点,它的工作原理正如我预期的那样(即,我无法重现您的问题)。它有点不同,因为我没有制作 TabBar 应用程序,但我仍然希望这会有所帮助。我对 UIActionSheet 所做的就是这样显示:
[actionSheet showInView:self.view]
。也许这会起作用?抱歉这么仓促的回答,当我注意到这一点时,我正在出去。 :)
I just wrote a quick sample app to test this out and it worked just as I expected (i.e., I couldn't repro your issue). It was a little different in that I didn't do a TabBar application but I'm still hopeful this helps. What I did with the
UIActionSheet
was to show it like this:[actionSheet showInView:self.view]
. Maybe that will work?Sorry for the rushed answer, I was on my way out when this caught my eye. :)
我在 iOS 4.2 中也遇到过这样的问题。
我认为您应该尝试执行以下步骤:
2.现在在 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 方法中,调用单击的按钮索引的 presentModalView{} 方法如下:
3.您还可以尝试不同的延迟时间。
希望有帮助..
I have also faced problems like this with iOS 4.2.
I think you should try with the following steps:
2.Now in the - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex method,Call the presentModalView{} method for the clicked button index like this:
3.You can also try by different delay time.
Hope it helps..
我从 AlertBox/ActionSheet 调用 MailComposeView 时遇到了同样的问题,导致 MailCompseView 出现在不可见屏幕后面。
我通过在actionSheet按钮处理程序中调用dismissWithClickedButtonIndex:animated:解决了这个问题。
I had the same issue calling MailComposeView from AlertBox/ActionSheet caused the MailCompseView to come behind invisible screen.
I solved it by calling dismissWithClickedButtonIndex:animated: in the actionSheet button handler.
iOS5中该问题已得到解决。
The problem has been resolved in iOS5.