【发布时间】:2014-09-19 07:10:31
【问题描述】:
当您按下自定义视图上的按钮时,我想在 iOS8 上显示 (width: 200, height:300) 弹出框。当我这样做时,我将弹出窗口作为全屏弹出窗口。 (委托也不起作用。它不会调用prepareForPopoverPresentation 等...
如何正确显示宽度为 200、高度=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];
}
}
【问题讨论】: