Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

devildog820

macrumors member
Original poster
Sep 29, 2008
45
0
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];
 
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];
      }
];
 
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:?
 
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:?

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.

----------

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

Thanks! I'll give that a shot and see. In the meantime, I submitted a bug report to Apple.
 
I believe the viewDidAppear gets called AFTER the view appears. Maybe try viewWillAppear.

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.
 
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...
 
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!!!


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...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.