userMod2 userMod2 - 3 years ago 110
Objective-C Question

iOS 11 - Suggestions for Custom View Controller Not Loading - Crashing

My app has recently (iOS 11) started crashing when a custom UIViewController is loaded:

The crash occurs at the line:

PDFViewController *pdfvc = [self.storyboard instantiateViewControllerWithIdentifier:@"PDFView"];

I confirm:

  • In the storyboard I am referencing the correct custom class
    and the ID is correct

  • The super class has initWithCoder

The exact error I get is:

[PDFViewController initWithCoder:]: unrecognized selector sent to instance 0x1c0012320
2017-09-26 22:35:44.578082+0900 flightcomp[9764:3233421] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PDFViewController initWithCoder:]: unrecognized selector sent to instance 0x1c0012320'

Now I've really searched around crazy on this - been through so many StackOverflow and Google pages to find nothing.

So my question is - could someone, please suggest a handful of things that could likely be causing this issue so I can further debug.



The .h for PDFViewController looks like:

@interface PDFViewController : UIViewController <UIPrintInteractionControllerDelegate>

The .m for PDFViewController looks like:

@implementation PDFViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
return self;

- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view.

Answer Source

The issue is that Apple as of iOS 11 has now included PDFKit as a framework. I believe that PDFViewController is now a reserved name for this framework. I had the same issue and after changing PDFViewController to SuperDuperPDFViewController worked just fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download