Reputation: 236
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
Upvotes: 4
Views: 2097
Reputation: 9040
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.
Upvotes: 0
Reputation: 166
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;
}
Upvotes: 10
Reputation: 3939
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.
Upvotes: 0