0
votes

A very simple Swift code to use ARKit. Mainly let Xcode create an ARKit App and run it. I work fine and shows de Plane.

BUT, when adding to the Storyboard a Navigation Controller and creating a small Menu, with the entry for the Plane Demo and calling now the same ARKit sample, the app crashes.

    switch menuItemIndex {
    case 0:
        let controller = AvionViewController()
        self.navigationController?.pushViewController(controller, animated: true)

    default:
        print("something")
    }

The crash is:

2017-06-27 08:08:26.317187-0500 ARDemo[1868:432582] [DYMTLInitPlatform] platform initialization successful fatal error: unexpectedly found nil while unwrapping an Optional value 2017-06-27 08:08:29.546679-0500 ARDemo[1868:432449] fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

So that means, when running the ARKit demo ViewController directly, it works, but when calling the ViewController from another one, the app crashes.

On the other side, when not using @IBOutlet, creating the ARSCNView programmatically and add to view, the app works fine.

Doing the same in Objective-C doesn't produce any crash. Strange?

Any idea?

1
That error is nothing to do with this code. It looks like it's possibly to do with the init method of AcionViewContirller. What's in there?Fogmeister

1 Answers

1
votes

If you are using a storyboard for navigation, that is not how you should instantiate a view controller.

You have to call let controller = self.storyboard?.instantiateViewController(withIdentifier: "yourViewControllersStoryboardID")