iOS UI causes crash after pushing/popping second view controller

260 Views Asked by At

In my iOS app, the entire user interface is coded programmatically, meaning no xibs or storyboards. All works well until I add another view controller via a UINavigationController.

The first view controller works well, and when the second view controller is pushed, it works well too. But after the second view controller pops itself, and the first view controller re-appears, any interaction with any of the elements of the user interface crashes the app.

Any idea what may be causing this?

UPDATE: Screenshot of exceptionexception

1

There are 1 best solutions below

7
On BEST ANSWER

There's a crash log that's generated when the app crashes. All the messages, along with the stack backtrace are there.

You can see a device's crash logs by connecting it to your Mac, then opening the Devices window, and viewing the device logs.

But it's easier to just debug this within Xcode, by connecting your device, then building and running it in Xcode, on the device.

When the app crashes (due to some exception), Xcode can catch this, and control will be transferred to the debugger.

You can add an Exception Breakpoint in Xcode to stop your app as soon as the exception occurs.

To add an exception breakpoint, switch to the Breakpoint Navigator. Click the small + button at the bottom of the pane, and select Add Exception Breakpoint.

Once the app crashes, you can look at the stack backtrace. The first few items on the call stack will likely be in Apple's code, but slightly further back will be a call from your view controller, showing the line which revealed the problem.

As to what is specifically wrong, it could be any number of things. We can't specifically help unless you share code that show the properties for those objects, and where they are (de)allocated.