PopOver 在左侧向上打开+iphone

发布于 2024-12-18 16:42:14 字数 768 浏览 2 评论 0原文

我想在按钮单击事件上打开一个弹出窗口。 如下图所示: 在此处输入图像描述

但我得到的是:

在此处输入图像描述

我用于弹出窗口的代码是:

PopOver *PopOver_obj=[[PopOver alloc]initWithNibName:@"PopOver_ipad" bundle:nil ];      
UIPopoverController  *popoverController = [[UIPopoverController alloc] initWithContentViewController:PopOver_obj];     
popoverController.delegate = self;     
CGSize maximumLabelSize = CGSizeMake(320.0f,200.0f);
popoverController.popoverContentSize = maximumLabelSize;
CGRect rect = CGRectMake(100,100, 200.0f, 100.0f);  
[popoverController presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

I want to open a popover on button click event.
Like below image:
enter image description here

But what i m getting is:

enter image description here

The Code i had used for the popover is:

PopOver *PopOver_obj=[[PopOver alloc]initWithNibName:@"PopOver_ipad" bundle:nil ];      
UIPopoverController  *popoverController = [[UIPopoverController alloc] initWithContentViewController:PopOver_obj];     
popoverController.delegate = self;     
CGSize maximumLabelSize = CGSizeMake(320.0f,200.0f);
popoverController.popoverContentSize = maximumLabelSize;
CGRect rect = CGRectMake(100,100, 200.0f, 100.0f);  
[popoverController presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一世旳自豪 2024-12-25 16:42:14

更新

对于 iOS 5,您可以使用弹出窗口的 popoverLayoutMargins 属性来设置相对于设备屏幕边缘的插入。有关更多详细信息,请参阅


据我从你的屏幕截图中看到,你有一个黑色视图和一个白色视图,但你在他们的超级视图中显示弹出窗口。

您可以尝试使用 - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view allowedArrowDirections:(UIPopoverArrowDirection)arrowDirectionsAnimated:(BOOL)animated 方法并将白色视图作为 传递>view 方法的参数和 UIPopoverArrowDirectionUparrowDirections 参数

我认为这可能会限制弹出窗口超出视图,从而将其保留在 + 按钮下。

让我知道这是否有帮助。

UPDATE

For iOS 5 you can use popoverLayoutMargins property of the popover to set an inset relative to the device's screen edges. See this for more detail.


As far as I can see from your screenshot you have a black colored view and a white one but you are showing the popup in their superview.

You can try using - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated method and pass the white view as the view argument of the method and UIPopoverArrowDirectionUp for the arrowDirections argument.

I think that might restrict the popover to go outside the view thus keeping it under your + button.

Let me know if that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文