Tag Archives: iPad

How to fix "setPreferredContentSize" error in iOS 6 iPad Apps

xcodeThere is a bug in Xcode 5 in the Master Detail Template which manifests when you try and run it on iPads running iOS 6.x. The app will work fine on iOS 7 but won’t even start in iOS 6. The full error message is something like this:

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[MasterViewController setPreferredContentSize:]: unrecognized selector sent to instance 0x7a95580’

The problem is with a code snippet in MasterViewController.m, first method. It looks like this:

This content is for members only.

Here we check if our current view controller (self) responds to preferredContentSize, and if it does, we’ll call what Apple recommend. If that’s not the case we simply won’t.

Adios exception!