我明白這個問題很多時候在STackOverflow上,也有很多在互聯網上。我也問過相關的問題是相同的,但環境不同,請耐心等待,因爲我無法找到解決此任務的方案。iOS:無法顯示登錄成功之前的登錄
我正在使用Xcode 5,使用Storyboard。我的項目是基於Tab的,並在故事板中添加了一個LoginViewController。我的勝利是在Tabs之前顯示LoginViewController。我嘗試了幾種來自不同網站的方式,但沒有完全適用。有了這段代碼,我可以首先獲得LoginViewController,但無法獲得Tabs控制器。在我的AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
self.tabBarController = [[MC_MainTabBarController alloc] init];
LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"];
[self.window setRootViewController:loginViewController];
// This also works - it shows the login
//[[[[UIApplication sharedApplication] delegate] window] setRootViewController:loginViewController];
// With this Login doesn't come only
//[loginViewController setModalPresentationStyle:UIModalPresentationFullScreen];
//[tabCtrler presentViewController:loginViewController animated:NO completion:nil];
return YES;
}
在我LoginViewController.m - 在結束loginBtnClicked事件,我呼籲:
NSLog(@"Showing TabController");
MC_AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.window setRootViewController:appDelegate.tabBarController];
在上述各行的執行,我得到黑色的屏幕和下面的警告:
Showing TabController
Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation.
Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation.
任何人都可以請幫助我。我從最近2天就陷入了這個問題。
任何幫助,高度讚賞。
也許我的回答可以幫助你:http://stackoverflow.com/questions/19962276/best-practices-for-storyboard-login-screen-handling-clearing-of-data-upon-logou/21877460#21877460 –
@dimimpou,非常感謝。你的回答幫了我。也有通知的想法。雖然我爲我的問題實施了特雷弗格曼的回答,但也從您的回答中採納了想法。謝謝。 – Tvd
很高興我能幫到你。 –