简体   繁体   中英

iOS: pushViewController freezes the app

I am a new iOS developer working on some legacy code. I learned from the code that to launch a new screen, I can do:

SomeViewController* view = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:view animated:YES];
[view release];

I have a screen B is launched from screen A. I need to further launch a screen C from screen B. The flow is A -> B -> C. when I do B->C, the app freezes and the screen looks like this:

在此处输入图片说明

However when I do A->C, it's working perfectly. Has anyone seen this before? Really appreciate your help.

It's hard to tell what the true problem may be without seeing more code. However, I do notice two problems:

  1. It is typical to see a navigation bar being displayed when you are pushing viewcontrollers onto the UINavigationController stack. I don't see a navigation bar in your screen shot. You may need to embed a UINavigationController.
  2. This was somewhat mentioned already in one of the comments. Pushing a UIView onto a UIViewController stack is an undifined action--you should be pushing a UIViewController. For example:

    [self.navigationController pushViewController:myViewControllerForViewC animated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM