当您按下自定义视图上的按钮时,我想在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];
}
}
答案 0 :(得分:3)
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{
return UIModalPresentationNone;
}