0

I'm really stumped here.

_vc = [[VLCKitViewControlleriPhone alloc]initWithNibName:@"VLCKitViewControlleriPhone" bundle:nil];
_vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:_vc animated:YES completion:nil];

Gives me EXC_BAD_ACCESS (code = 2, address = 0x0) when the presentViewController method is called. The view controller is NOT nil. It also happens with or without a nib name. If I comment out the presentViewController line, the rest of the code continues fine, including method calls made to the view controller itself. The view controller is running, I just can't see anything because it's not actually showing the view.

I enabled NSZombies and tried it with Instruments running, but it's not showing me anything. The app just quits and instruments stops without giving me any information. Anyone know what the problem might be?

Joseph Toronto
  • 1,882
  • 1
  • 15
  • 29
  • Is anything written to the console? – user1118321 Apr 05 '14 at 20:35
  • Have you tried putting breakpoints on VLCKitViewControlleriPhone's viewDidLoad/WillAppear/DidAppear methods to see if it's getting that far? – mackworth Apr 05 '14 at 20:36
  • Does your `VLCKitViewControlleriPhone` has a `xib`? (Because, you're saying that if it has or not a `nib` name, sounds strange. If I remember correctly, it would show an error if the xib does not exist. – Larme Apr 05 '14 at 20:38
  • if you're running this on an iPod/iPhone, you cannot use UIModalPresentationFullScreen. That is only for iPad. Try using UIModalTransitionStyleCoverVertical, UIModalTransitionStyleFlipHorizontal, UIModalTransitionStyleCrossDissolve, UIModalTransitionStylePartialCurl if using iphone – user2277872 Apr 05 '14 at 20:56
  • To answer the above questions: 1)Nothing is written to the console, 2)It steps completely through ViewDidLoad/ViewWillAppear with no problem, 3)The XIB file actually does exist, 4)I tried it various ways and it doesn't seem to make a difference. – Joseph Toronto Apr 05 '14 at 21:47
  • Alright, it seems there's an issue with the view controller itself. I haven't pinned it down where exactly but I commented out a lot of the code in it and I was able to get it to present. – Joseph Toronto Apr 05 '14 at 23:07
  • it's possible that when the new controller is presented, your view controller's ViewWillDisappear or ViewDidDisappear gets called and tries to access something that you've (over) released... you can try setting breakpoints in those and see if they hit before you crash. – RobP Apr 06 '14 at 01:12

1 Answers1

0

You can try this

if ([controller respondsToSelector:@selector(setModalPresentationStyle:)])
{
    [controller setModalPresentationStyle:UIModalPresentationFullScreen];
} else {
    [controller setModalPresentationStyle:UIModalPresentationFormSheet];
}
Erhan
  • 908
  • 8
  • 19
  • 1
    This answer doesn't make sense. You're checking if `controller` responds to `setModalPresentationStyle:` and calling it if it does, which is fine. But then if it doesn't respond, you're still calling it with a different argument. If it doesn't respond to the selector, calling that selector with a different argument isn't gonna make it magically respond – Chris Sep 07 '15 at 15:58