4

I have been struggling with switching between views using the UINavigationalController. I have used this system many times without issue but in my new app it isn't working properly.

Here is the issue: When i am pushing a new view controller i use the following code:

NewViewController *newVC = [[NewViewController alloc] initWithNib:@"NewView" bundle:nil];
[self.navigationController pushViewController:newVC animated:YES];
[newVC release];

The code I am using to return to the previous view inside of the newVC is:

[self.navigationController popViewControllerAnimated:YES];

I was reading that this could potentially be releasing the self.navigationController itself so I implemented this code:

UINavigationController *nc = [self navigationController];
[nc popViewControllerAnimated:YES];

What results is a smooth transition to the newVC with no white flash, but when returning to the original page the screen flashes white as if it is releasing the newVC before transitioning back to the original page. HOWEVER! When debugging I placed breakpoints on viewWillAppear of the original page and on the dealloc of the newVC and the viewWillAppear + transition with white flash all complete BEFORE the dealloc of the newVC is called.

If anyone could please help shine some light on this I would greatly appreciate it.

Thanks! ~Arash

Community
  • 1
  • 1
iOS4Life
  • 206
  • 2
  • 12
  • This is an old post but I am currently facing the exact same problem. Did you solve this? – hklel Aug 24 '16 at 02:50
  • Alex, I don't remember how I solved this issue, but if you are still experiencing this problem, try KaiDANTE's suggestion below. If it works, let us know here and I will mark it as the answer for future reference :). – iOS4Life Aug 25 '16 at 14:08

3 Answers3

10

This is an old post, but for those who may run into this issue in the future, I have solved it by setting the clipsToBounds property of the view of the ViewController to "TRUE"

-(void)viewDidLoad {
    [super viewDidLoad];
    self.view.clipsToBounds = YES;
}
Titouan de Bailleul
  • 12,622
  • 11
  • 60
  • 114
KaiDANTE
  • 166
  • 1
  • 6
0

FWIW, this same issue happened for me in a Swift app. The root cause appeared to be that I was doing this:

self.navigationItem.rightBarButtonItem = nil

...to dynamically hide the button, where the UIBarButtonItem had an outlet in the current UIViewController.

I did not actually need an IBOutlet for that button, so I removed the outlet, and it worked.

Daniel
  • 8,301
  • 4
  • 42
  • 65
0

Try changing the background colors of the various views on the navigation stack to different recognizable colors (including the main window). One of them might be showing for some reason, and if each one has a different color you can determine which one is the culprit pretty easily.

Sofi Software LLC
  • 3,516
  • 1
  • 31
  • 31