[英]display view controller before tab bar controller
我正在開始我的第一個iPhone應用程序。 我正在使用xcode 4.3.3,IOS 5和情節提要的原理。
該應用程序的主屏幕是一個標簽欄控制器,如果用戶未登錄,我想在主屏幕之前顯示一個登錄信息。
我找不到解決方案:如果我必須將文件AppDelegate.m與didFinishLaunchingWithOptions()函數一起使用,或者將我的控制器文件與viewDidAppear()函數一起使用,或者使用其他功能。
如果有人可以幫助我解決問題
謝謝。
您可以在登錄屏幕上使用另一個視圖,並在nsuserdeafault中使用保存布爾值,然后在應用啟動時檢查nsuserdefault並根據該視圖顯示視圖。
然后,您可以在委托.m或view出現的任何地方調用。
只需在啟動應用程序時創建登錄屏幕,並在登錄成功后從此處推動標簽欄控制器...
最好在AppDelegate.m中添加功能,以消除未登錄時出現的不需要的窗口(如果在ViewDidAppear方法中編寫代碼,則在重定向到登錄頁面之前會先顯示您的主視圖)。
另一種方法是添加新的視圖控制器,並根據視圖控制器的ViewDidAppear方法的登錄狀態檢查重定向到的位置。
嘗試使用Modal View Controller, 文檔
在didFinishLaunchingWithOptions()
或viewWillAppear()
嘗試執行以下操作:
YourViewController *viewController = [[YourViewController alloc] initWithNibName:@"YourViewController" bundle:nil];
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
viewController.modalPresentationStyle = UIModalPresentationFormSheet;
//Present as Model view controller
["presentedViewController" presentModalViewController:viewController animated:YES];
//release it After presenting to it
[viewController release];
然后將其刪除,請調用: dismissModalViewControllerAnimated:
(docs)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.