從更新到XCode 4.2和iOS5後,當我的應用程序啓動時,我無法再顯示我的Modal登錄視圖控制器。我有一個4選項卡tabBar應用程序,需要初始登錄才能使用。由於升級它只顯示登錄後應顯示的第一個視圖 - 基本上它不會加載負責處理登錄的模式視圖控制器,並直接轉到應用程序的其他功能。與4.3版本完全相同的代碼在iOS 5中不起作用 - 它讓我難倒了!我寧願現在不使用StoryBoard,因爲這應該工作。我在下面的tabBar上粘貼了viewDidLoad的第一個選項卡 - 它進入if語句,但從未真正顯示登錄視圖。如果有人能幫助我,我真的很感激!我在這裏錯過了什麼嗎?謝謝 -iOS5 Modal登錄不再在XCode 4.2中啓動
viewDidLoad中:
- (void)viewDidLoad
{
// Call the super first
[super viewDidLoad];
// Only login once
PinPointMeAppDelegate *appDelegate = (PinPointMeAppDelegate *)[[UIApplication sharedApplication] delegate];
// It's not loading like it did pre-iOS5 - why?
NSLog(@"LOADING VIEW %d",appDelegate.loggedInFlag);
// Only show the login view if we aren't logged in
if (appDelegate.loggedInFlag == 0) {
// Initialize our view controller that handles logging in
ModalLogin *loginView = [[ModalLogin alloc] initWithNibName:@"ModalLogin" bundle:nil];
// Set the delegate to self
loginView.delegate = self;
// Animate presenting the nib "ModalPlace" modally
loginView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:loginView animated:NO];
// Set the flag that the modal login view is shown
self.modalShown = 1;
}
}
AppDelegateDidFinishLaunching:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Begin determining the User's Lat/Lon
// Start the Location Manager to get current coordinates to determine where the mapview should zoom
self.locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
// Set the logged - in flag to 0 since we just launched
loggedInFlag = 0;
// Initially no alert views are shown
alertViewShown = 0;
// Initialize the splash screen to Not Shown
splashScreenFlag = 0;
// Add the tab bar controller's view to the window and display.
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
// Set the delegate for the tabBarController
tabBarController.delegate = self;
// Un-Hide the status bar
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
return YES;
}
感謝您的迴應 - 我做到了這一點,它確實顯示了現在的加載視圖 - 但直到它實際上簡要顯示了其他視圖後才能看到,直到登錄後才能看到。所以它閃爍視圖不應該約0.5秒後才能看到,然後正確顯示登錄視圖。任何想法如何糾正這? – PhilBot
哦,我已經在3GS和4S上嘗試了這一結果。 – PhilBot
@ Phil999這很奇怪,這就是我正在做的事情,它不會爲我做這件事,你有沒有Default.png ?,這可能是我爲什麼看不到它。 –