[英]UITabBarController delegate with storyboard
我知道如果我有以tabBar開頭的rootViewController我可以像這樣創建UITabBar:
UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
tabController.selectedIndex = [defaults integerForKey:kOptionLastTabSelectedKey];
tabController.delegate = self;
但我的問題是:如果tabBar不是我的rootView,我如何創建tabBar? 我的應用程序以簡單的viewController登錄開始,登錄后將出現tabBar。 其次,我應該在appDelegate或其他地方創建標簽欄?
謝謝!!!
我認為你應該使你的tabBarController成為你的窗口的rootViewController,而不是通過窗口rootViewController模擬地呈現你的loginViewController,登錄后你可以解除loginViewController。檢查以下代碼。
[self.window.rootViewController presentModalViewController:loginViewController animated:YES];
並在登錄后使用委托方法或在loginViewController類中編寫以下代碼並解除loginViewController。
[self.window.rootViewController dismissModalViewControllerAnimated:YES];
要么
[self dismissModalViewControllerAnimated:YES];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.