PopOver 在左侧向上打开+iphone
我想在按钮单击事件上打开一个弹出窗口。 如下图所示:
但我得到的是:
我用于弹出窗口的代码是:
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:
But what i m getting is:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新
对于 iOS 5,您可以使用弹出窗口的
popoverLayoutMargins
属性来设置相对于设备屏幕边缘的插入。有关更多详细信息,请参阅此。据我从你的屏幕截图中看到,你有一个黑色视图和一个白色视图,但你在他们的超级视图中显示弹出窗口。
您可以尝试使用
- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view allowedArrowDirections:(UIPopoverArrowDirection)arrowDirectionsAnimated:(BOOL)animated
方法并将白色视图作为传递>view
方法的参数和UIPopoverArrowDirectionUp
的arrowDirections 参数
。我认为这可能会限制弹出窗口超出视图,从而将其保留在
+
按钮下。让我知道这是否有帮助。
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 theview
argument of the method andUIPopoverArrowDirectionUp
for thearrowDirections 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.