presentModalViewController - ViewController在呈现后自动消失

发布于 2025-01-03 15:58:50 字数 718 浏览 0 评论 0原文

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

我的视图层次结构如下所示:

UITabBarController 包含 5 个选项卡,每个选项卡都包含一个 UINAvigationController。 到目前为止一切都很完美。

现在我想通过 PresentModalViewController 方法呈现一个模式视图控制器 UITabBarController 使用以下代码行:

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

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

所发生的情况是,视图呈现出来,几秒钟后就神秘地消失了。 为什么会发生这种情况?我在任何时候都不会调用missModalViewController 方法。

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

问候, 弗洛里安

I am currently developing an iPhone App for my company and i ran into a strange thing.

My View Hierachy looks like this:

UITabBarController containing 5 Tabs with every Tab containing a UINAvigationController.
So far everything works perfect.

Now i want to present a modal View controller via the presentModalViewController method on the
UITabBarController using this lines of code:

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

The FilterOptionsView is a normal UIViewController containing nothing but a black background at the
moment.

What happens is that the view is presented and after a couple of seconds misteriously disappears.
Why is this happening? At no Point i am calling the dismissModalViewController method.

I already ran into this problem when presenting a mailcomposer.

greetings,
Florian

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

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

发布评论

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

评论(1

小女人ら 2025-01-10 15:58:50
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];

ps我建议不要将视图控制器命名为“filterView”,最好将其命名为“filterViewController”

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

or a better approach might be:

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

to dismiss:

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

p.s. I recommend not naming a view controller "filterView" it would be better named "filterViewController"

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