Crash after presenting View Controller modal on iPhone
Asked Answered
K

0

1

I´m trying to implement a Popover for iPad and iPhone. Before iOS 9, there were different ViewController for iPad and iPhone. With iOS9 there should be a possibility to do this with a normal ViewController and different PresentationStyles? (Deployment Target is iOS 9.0) Am i right?

according to this post:

Stackoverflow answer from Daniel Galasko

I tried to implement this answer in objective c.

_mediaTypePopoverVC = [[MediaTypePopoverVC alloc] initWithProductId:PRODUCT_ID_NONE_PARENT];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_mediaTypePopoverVC];
    _popoverVC = [[UIViewController alloc] init];
    _popoverVC.modalPresentationStyle = UIModalPresentationPopover;
    _popoverVC.preferredContentSize = CGSizeMake(650.0, 364.0);
    _popoverVC.popoverPresentationController.delegate = self;


    [navigationController setViewControllers:@[_popoverVC]];

    _mediaTypePopoverVC.title = POPOVER_TITLE(mediaType.name_en, (int) [mediaList count]);
    _mediaTypePopoverVC.isCommonMediaList = YES;

    [Logic sharedInstance].currentPopoverController = _popoverVC;
    [self presentViewController:_popoverVC animated:true completion:nil];
     UIPopoverPresentationController *popover = _popoverVC.popoverPresentationController;
    if(nil != popover){
        popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
        popover.sourceView = baseButton;
        popover.sourceRect = baseButton.bounds;

    }

The crash will appear in this Line:

[self presentViewController:_popoverVC animated:true completion:nil];

My Log will give me only this:

Signal: SIGABRT (signal SIGABRT)
Keratose answered 19/11, 2015 at 8:5 Comment(2)
This doesn't look remotely close to the solution I outlined in my post? You have created an unnecessary amount of ViewControllersSprung
Start simple, get my solution working and then build it up into yours:)Sprung

© 2022 - 2024 — McMap. All rights reserved.