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

Posted

技术标签:

【中文标题】iOS5 模式登录不再在 XCode 4.2 中启动【英文标题】:iOS5 Modal Login No Longer Launches in XCode 4.2 【发布时间】:2011-10-15 01:26:47 【问题描述】:

自从更新到 XCode 4.2 和 ios5 后,当我的应用启动时,我无法再显示我的 Modal Login 视图控制器。我有一个 4 选项卡 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;

【问题讨论】:

【参考方案1】:

尝试在viewDidAppear 上展示您的模式,这应该可以解决问题。

【讨论】:

感谢您的回复-我这样做了,它现在确实显示了加载视图-但直到它实际上简要地显示了后面的另一个视图,在登录之前不应该看到它。所以它闪烁不应该看到的视图约 0.5 秒,然后正确显示登录视图。任何想法如何纠正这个?? @Phil999 这很奇怪,这就是我正在做的事情,但它对我没有这样做,你有 Default.png 吗?这可能是我看不到它的原因。 @Rob Bajorek 我为我的应用程序尝试过,但它只适用于 viewDidAppear,但我的并没有呈现 OP 正在谈论的行为,你看到的第一件事是模态视图没有闪烁。 感谢您的回复 - 我确实尝试了 viewWillAppear 和 viewDidLoad(viewDidLoad 在 4.3 中工作),但在 iOS5 上都没有工作。 viewDidAppear 允许显示登录,但在显示登录视图之前,模式登录后面的视图仍然有很短的闪烁。我没有使用任何模态视图动画,并且我还确保我的 Default.png 在那里。仍在努力解决这个问题! 感谢您解决了我的问题【参考方案2】:

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

正如 Oscar 指出的那样,您需要在 viewDidAppear 中展示您的模态视图

另外,默认情况下,您的 AppDelegate 中可能有 [window makeKeyAndVisible] application:didFinishLaunchingWithOptions:

您必须在 显示您的模态视图后进行调用。

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

【讨论】:

以上是关于iOS5 模式登录不再在 XCode 4.2 中启动的主要内容,如果未能解决你的问题,请参考以下文章

getJSON 在 Xcode 4.2 和 ios5 中无法使用 PhoneGap1.1.0

ios 5 模拟器在 xcode 4.2 中没有响应

如何在 xCode 4.2 中为两个方向正确设置 iPad 启动图像

iphone:使用 iOS 5 和 Xcode 4.2 提交应用程序? [关闭]

Xcode 4.2/iOS 5 下控制台中没有异常堆栈跟踪?

Xcode 4.2 调试不象征堆栈调用