iOS8上的UIPopoverPresentationController始终以全屏显示

时间:2014-09-19 07:10:31

标签: ios8 uipopovercontroller

当您按下自定义视图上的按钮时,我想在iOS8上显示(宽度:200,高度:300)popover。当我这样做时,我将popover作为全屏弹出窗口。 (代表也不起作用。它不会调用prepareForPopoverPresentation等......

如何正确显示popover的宽度:200,height = 300以及委托不调用的问题是什么?

-(void)buttonPressed:(UIView*)sender{
    CGRect rect=[self convertRect:sender.frame fromView:sender.superview];

    rect.origin.y-=10;

    rect.size.width=60;
    rect.size.height=60;

    self.stViewController=[[STViewController alloc]init];


    self.stViewController.view.frame=CGRectMake(0, 0, 200, 300);

    self.stViewController.modalPresentationStyle=UIModalPresentationPopover;
    self.stViewController.preferredContentSize = CGSizeMake(200,300);

    if (self.stViewController.popoverPresentationController)
    {
        self.stViewController.popoverPresentationController.delegate=self;
        self.stViewController.popoverPresentationController.sourceView=self.superview;
        self.stViewController.popoverPresentationController.sourceRect=rect;
        self.stViewController.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionLeft|UIPopoverArrowDirectionRight;

        [[(AppDelegate*)[UIApplication sharedApplication].delegate mainViewController] presentViewController:self.stViewController animated:YES completion:nil];
    }
}

1 个答案:

答案 0 :(得分:3)

-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
    return UIModalPresentationNone;
}
相关问题