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!

2 thoughts on “How to fix "setPreferredContentSize" error in iOS 6 iPad Apps

  1. The problem is, setPreferredContentSize is only available in IOS 7.0.

    When you found the setPreferredContentSize you should do something like this :

    at the header

    now wherever u need to check whether ios version is greater or less and similarly set the contentsize

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.