Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 按钮的presentPopoverFromRect超出范围_Iphone_Objective C_Ios_Ipad_Uipopovercontroller - Fatal编程技术网

Iphone 按钮的presentPopoverFromRect超出范围

Iphone 按钮的presentPopoverFromRect超出范围,iphone,objective-c,ios,ipad,uipopovercontroller,Iphone,Objective C,Ios,Ipad,Uipopovercontroller,因此,我使用显示自定义视图控制器弹出窗口。我有一个UIView,里面有另一个叫做containerView的UIView。在这个容器视图中,我有一个UIButton。这就是我想展示我的府绸的地方。以下是我所做的: [self.popoverDialog presentPopoverFromRect:sender.frame inView:self.containerView permittedArrowDirections:UIPopoverArrowDirectionDown animat

因此,我使用显示自定义视图控制器弹出窗口。我有一个UIView,里面有另一个叫做containerView的UIView。在这个容器视图中,我有一个UIButton。这就是我想展示我的府绸的地方。以下是我所做的:

  [self.popoverDialog presentPopoverFromRect:sender.frame inView:self.containerView permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
问题是箭头和所有内容都是从这个按钮显示的,但是弹出框超出了self.containerView的范围。我怎样才能使POPOR显示在containerView范围内

编辑:

一幅画抵得上千言万语,所以它就是: 浅灰色是我上面提到的containerView。理论上,popover应该显示在浅灰色范围内,而不是向外


对于popover中包含的视图,转到其视图控制器并设置其属性contentSizeForViewInPopover。在这里,您可以设置大小,使其符合containerView的边界

OP希望定位popover,使其仅显示在其容器视图中。我在wepopcovercontroller.m文件中找到了这段代码

- (void)repositionPopoverFromRect:(CGRect)rect
                       inView:(UIView *)theView
     permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections {

CGRect displayArea = [self displayAreaForView:theView];
WEPopoverContainerView *containerView = (WEPopoverContainerView *)self.view;
[containerView updatePositionWithAnchorRect:rect
                                displayArea:displayArea
                   permittedArrowDirections:arrowDirections];

popoverArrowDirection = containerView.arrowDirection;
containerView.frame = [theView convertRect:containerView.frame toView:backgroundView];
}


您可能会调用此方法,它可能会重新定位您的popover,使其现在位于容器viw中。

对于包含在popover中的视图,请转到其视图控制器,并设置其属性ContentSizeForViewPopover。在这里,您可以设置大小,使其符合containerView的边界

OP希望定位popover,使其仅显示在其容器视图中。我在wepopcovercontroller.m文件中找到了这段代码

- (void)repositionPopoverFromRect:(CGRect)rect
                       inView:(UIView *)theView
     permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections {

CGRect displayArea = [self displayAreaForView:theView];
WEPopoverContainerView *containerView = (WEPopoverContainerView *)self.view;
[containerView updatePositionWithAnchorRect:rect
                                displayArea:displayArea
                   permittedArrowDirections:arrowDirections];

popoverArrowDirection = containerView.arrowDirection;
containerView.frame = [theView convertRect:containerView.frame toView:backgroundView];
}


您可以调用此方法,它可能会重新定位popover,使其现在位于容器viw中。

我已经这样做了。。这个尺寸不错。。但是只想保持它的大小,这样它就不会超出范围。你能提供一个图像吗?我很难理解你说的越界是什么意思。它仍然完全在屏幕内吗?啊,这是有道理的。因此,您可以做的不是从发送者的框架中呈现popover,而是创建一个偏移的CGRect。问题是popover的箭头来自它的中心。我试图寻找一种方法,你可以做这个偏移,让箭头更向右。你知道WEPopover中有没有一种方法能做到这一点吗?嗯…我认为没有任何方法能做到这一点。我确实创建了CGRect,而不是从发送者那里展示它,但是正如您所提到的,箭头不在正确的位置,我在WEPopover支持的文档中发现了这一点,用于限制显示popover的区域:为提供给presentPopover方法的视图实现协议WePopopOverprentView,并实现-CGRectdisplayAreaForPopover。也许你可以试试。我已经试过了。。这个尺寸不错。。但是只想保持它的大小,这样它就不会超出范围。你能提供一个图像吗?我很难理解你说的越界是什么意思。它仍然完全在屏幕内吗?啊,这是有道理的。因此,您可以做的不是从发送者的框架中呈现popover,而是创建一个偏移的CGRect。问题是popover的箭头来自它的中心。我试图寻找一种方法,你可以做这个偏移,让箭头更向右。你知道WEPopover中有没有一种方法能做到这一点吗?嗯…我认为没有任何方法能做到这一点。我确实创建了CGRect,而不是从发送者那里展示它,但是正如您所提到的,箭头不在正确的位置,我在WEPopover支持的文档中发现了这一点,用于限制显示popover的区域:为提供给presentPopover方法的视图实现协议WePopopOverprentView,并实现-CGRectdisplayAreaForPopover。也许你可以试试。