iOS5模式登录不再在XCode 4.2中启动

时间:2011-10-15 01:26:48

标签: iphone objective-c cocoa-touch modalviewcontroller ios5

自从更新到XCode 4.2和iOS5后我的应用启动时,我无法再显示我的模态登录视图控制器。我有一个4 tab tabBar应用程序,需要初始登录才能使用。由于升级它只显示登录后应显示的第一个视图 - 基本上它从不加载负责处理登录的模态视图控制器并直接进入应用程序的其他功能。在4.3中工作的完全相同的代码在iOS 5中不起作用 - 它让我难过!我现在不想使用StoryBoard,因为这应该可行。我已经将viewDidLoad粘贴到下面tabBar上的第一个选项卡 - 它进入if语句但从未实际显示登录视图。如果有人能帮助我,我真的很感激!我在这里错过了什么吗?谢谢 -

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;
}

2 个答案:

答案 0 :(得分:2)

尝试在viewDidAppear上展示你的模态,应该修复它。

答案 1 :(得分:0)

使用iOS 5兼容性时遇到了同样的问题。

正如奥斯卡指出的那样,你需要在viewDidAppear

中展示你的模态视图

此外,默认情况下,您的AppDelegate [window makeKeyAndVisible]

中可能有application:didFinishLaunchingWithOptions:

在显示模态视图后,您必须拨打电话。

Default.png将显示,直到您创建一个UIWindow键并且可见,这样您就不会再看到闪烁。