modal view not appearing in iOS 5 (but 4.3 works)

Discussion in 'iOS Programming' started by devildog820, Nov 2, 2011.

  1. devildog820 macrumors member

    Joined:
    Sep 29, 2008
    #1
    I've seen a couple of similar threads but none had answers and were from the earlier betas. I'm calling the code segment below in the viewDidLoad section of the view that loads when the app loads. In 4.3 this worked great. In 5.0 it doesn't load. I don't get a crash, setting a breakpoint reveals nothing so far. The view simply doesn't load.
    Thoughts?

    Code:
    LoginViewController *controller = [[LoginViewController alloc] init];
    
    [self presentModalViewController:controller animated:NO];
    
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    This is a hack, but you might want to try delaying the code until after the current event fully processes.

    Code:
    [[NSOperationQueue mainQueue]
       addOperationWithBlock:
          ^{
             LoginViewController *controller = [[LoginViewController alloc] init];
             [self presentModalViewController:controller animated:NO];
          }
    ];
    
     
  3. lefooey macrumors member

    Joined:
    Dec 26, 2009
    Location:
    Spokane, WA
    #3
    I'm assuming this is some form of initial login screen that you're putting on top of your normal start-up view?

    Why not place this in viewDidAppear:?
     
  4. devildog820 thread starter macrumors member

    Joined:
    Sep 29, 2008
    #4
    Correct, it's a login screen.

    I also tried viewDidAppear, but it won't work on startup. If I leave the tab and come back, it will work every time (when in viewDidAppear). I'm guessing iOS 5 changed something with rendering priorities that is causing this issue.

    ----------

    Thanks! I'll give that a shot and see. In the meantime, I submitted a bug report to Apple.
     
  5. Shawnpk macrumors 6502

    Joined:
    Jan 13, 2011
    Location:
    Los Angeles, CA
    #5
    I believe the viewDidAppear gets called AFTER the view appears. Maybe try viewWillAppear.
     
  6. lefooey macrumors member

    Joined:
    Dec 26, 2009
    Location:
    Spokane, WA
    #6
    Yes, viewDidAppear: is after the view is on screen. I was thinking since he's using a modal view on top of that that what he was looking for is an overlay on top of the existing view that basically prompts for log in.

    I'd put a couple of NSLog statements in your LoginViewController class to make sure you're actually getting called when and where you think you are. I think the problem is there, not in the class that's calling it.
     
  7. devildog820 thread starter macrumors member

    Joined:
    Sep 29, 2008
    #7
    I did mean viewWillAppear. I've just been coding too much today. :D

    The log statements and breakpoints all show everything is fine. And because it works flawlessly in iOS 4.3.3, I think it may be a bug. I'm just wondering if I am missing some iOS convention...
     
  8. lgarcia macrumors newbie

    Joined:
    Nov 14, 2011
    #8
    Hello!!!
    I'm getting the same error when i try to show a modal view ( "Login view")
    in ios 5.0. How did you solve it? Thanks for your help.
    Bye!!!


     

Share This Page