Crash after presenting View Controller modal on iPhone

依然范特西╮ 提交于 2019-12-11 10:06:14

问题


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)

来源:https://stackoverflow.com/questions/33798277/crash-after-presenting-view-controller-modal-on-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!