[英]How to show login-controller just before the tab-bar application launch?
嗨,我已經在iphone / ipad中完成了標簽欄應用程序。 完成所有操作后,客戶端需要一個用戶必須登錄才能進入第一個視圖的登錄控制器。第一個視圖是包含登錄按鈕和注冊按鈕的單一視圖,該視圖必須是第一個視圖,用戶點擊登錄即可重定向到登錄頁面即登錄頁面。 登錄后,用戶必須進入tabbarapp的第一個視圖。 我在appDidFinishLaunching
嘗試了此代碼
RootViewController *log = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
[window addSubview:tabController.view];
[window addSubview:log.view];
[window makeKeyAndVisible];
rootviewcontroller是singin注冊按鈕視圖,我在應用啟動時看到了此視圖。但是當我輸入singin時,它不會重定向到singin或登錄頁面。我的代碼是
pagesignIn *secondViewController = [[pagesignIn alloc]
initWithNibName:@"pagesignIn"
bundle:nil];
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:1];
//[UIView setAnimationCurve:UIViewAnimationTransitionFlipFromLeft];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:[[self navigationController] view] cache:YES];
[self.navigationController pushViewController:secondViewController animated:YES ];
[UIView commitAnimations];
但是什么都沒有做,所以我把這個[self.view removeFromSuperview];
到上面的代碼,現在我得到了按鈕操作,但是它沒有重定向到登錄頁面,但是重定向到了標簽欄應用程序的第一頁。單擊后如何進入登錄頁面登錄按鈕? 請幫我。 提前致謝。
我猜你的log
-ViewController沒有NavigationController。 在您的代碼中, self.navigationController
為nil
並且對nil
所有方法調用均self.navigationController
。
嘗試這個:
RootViewController *log = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
//create a new navigationcontroller
UINavigationController *navVC = [[UINavigationController alloc] initWithRootViewController:log];
[window addSubview:tabController.view];
[window addSubview:navVC.view]; //now add the navigationcontroller instead of the log-vc
[window makeKeyAndVisible];
[navVC release];
[log release];
但我建議您使用modal-viewcontroller
。 它要簡單得多(例如,您不必使用窗口的子視圖),並且可以更好地了解用戶的情況,即有兩種不同的視圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.