UIBarButtonItem causes app to crash

415 Views Asked by At

I'm learning to code in Objective-C by developing a simple app. I'm using a UISplitViewController which has UIBarButtonItem. When you tap an item on the left UINavigationController, shows up on the right one. This right one has a button inside which takes you to a web site, controlled by a browser controller; when tapped, up left on the UIBar appears a button to go back/to the previous view.

The problem is that when I tap this button, the app crashes and Xcode tells me the problem is the method viewWillDisappear in the browser controller. I've checked it up and down dozen times and can't find the error.

code & error

1

There are 1 best solutions below

1
On BEST ANSWER

Change

[self viewWillDisappear : animated];

to

[super viewWillDisappear : animated];

Your way creates an infinite recursion - method calling itself - visible also in Thread 1 call stack.