iphone - presentModalViewController - ViewController 在呈现后自动消失

标签 iphone ios modalviewcontroller

我目前正在为我的公司开发一个 iPhone 应用程序,我遇到了一件奇怪的事情。

我的 View 层次结构如下所示:

UITabBarController 包含 5 个选项卡,每个选项卡包含一个 UINAvigationController。 到目前为止一切正常。

现在我想通过 presentModalViewController 方法在 UITabBarController 使用这行代码:

-(void)callFilterOptions
{
    FilterOptionsView *filterView = [[FilterOptionsView alloc] init];
    [filterView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self.tabBarController presentModalViewController:filterView animated:TRUE];
}

FilterOptionsView 是一个普通的 UIViewController,只包含黑色背景 时刻。

发生的事情是 View 出现,几秒钟后神秘地消失了。 为什么会这样?我绝不会调用 dismissModalViewController 方法。

我在介绍邮件编辑器时已经遇到过这个问题。

问候, 弗洛里安

最佳答案

UINavigationController *myNavController = [self navigationController];
[myNavController presentModalViewController:filterView animated:TRUE];

或者更好的方法可能是:

UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController presentModalViewController:filterView animated:YES];

解雇:

UIApplication *myApp = [UIApplication sharedApplication];
noIBAppDelegate*appDelegate = (noIBAppDelegate*)myApp.delegate;
[appDelegate.tabBarController dismissModalViewControllerAnimated:YES];

附注我建议不要将 View Controller 命名为“filterView”,最好命名为“filterViewController”

关于iphone - presentModalViewController - ViewController 在呈现后自动消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9195830/

相关文章:

ios - 我可以从另一个模态视图显示一个模态视图吗

iphone - iOS - 知道模态视图何时被关闭

ios - 将我的 CustomCell.xib 连接到 Storyboard中的 tableView 时遇到问题

ios - 快速动画所有添加的 View alpha

iphone - 隐藏导航栏点击不工作

iphone - 如何使用 revmob 运行本地通知

javascript - React Native listView 项目删除未正确删除项目

ios - 当 Controller 以模态方式呈现时,将数据传递给不同的 View Controller ?

iphone - iOS - 如何执行 Clear 应用程序等视觉效果?

iphone - 在 iPhone 应用程序的高级版和免费版之间共享应用程序内购买 ID?