I am trying to create a MasterDetail application in Swift and it works well on iOS8 Simulator. However, when I tried this on my iPad iOS 7.1, I got this error:
**Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [UISplitViewController displayModeButtonItem]: unrecognized selector sent to instance**
This is in my AppDelegate.swift file (generated by Xcode, I haven’t added anything):
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let splitViewController = self.window!.rootViewController as UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as UINavigationController
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
splitViewController.delegate = self
let masterNavigationController = splitViewController.viewControllers[0] as UINavigationController
let controller = masterNavigationController.topViewController as MasterViewController
controller.managedObjectContext = self.managedObjectContext
return true
}
The problem arises from this line where the left button is created:
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem()
When I delete this line, it runs on iOS 7, but only the DetailView is displayed. When I scroll the left edge, MasterView does not appear (it is on the iOS 8 simulator), and basically there is no navigation to MasterView
If anyone has the same problem?
Thank!
source
share