簡體   English   中英

presentModalViewController - ViewController在呈現后自動消失

[英]presentModalViewController - ViewController automatically disappears after presenting

我正在為我的公司開發一個iPhone應用程序,我遇到了一個奇怪的事情。

My View Hierachy看起來像這樣:

UITabBarController包含5個Tabs,每個Tab包含一個UINAvigationController。 到目前為止一切都很完美。

現在我想使用以下代碼行通過UITabBarController上的presentModalViewController方法呈現一個模態View控制器:

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

FilterOptionsView是一個普通的UIViewController,目前只包含黑色背景。

會發生什么是視圖被呈現,並在幾秒鍾后大量消失。 為什么會這樣? 在沒有點我正在調用dismissModalViewController方法。

我在呈現mailcomposer時遇到過這個問題。

問候,弗洛里安

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”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM