单击 UIBarButtonItem 时 iPhone 中的弹出窗口

发布于 2024-12-29 22:02:03 字数 297 浏览 0 评论 0原文

我想在用户单击 UIBarButtonItem 时显示弹出窗口。为了让弹出窗口在 iPhone 上工作,我搜索并找到了 WEPopover

已编辑 : 抱歉,我的问题很混乱。我试图画一些类似于 iPad 弹出框的东西,但是是在 iPhone 上。我问是否有替代方案,例如在其他视图上添加 UIView 或从 iPhone SDK 中添加新组件。

谢谢。

I would like to show a popover when the user clicks on a UIBarButtonItem. To make a popover work on an iPhone, I have searched and found WEPopover

Edited : Sorry, my question was confusing. I was trying to draw something similar to the iPad popover, but in an iPhone. I was asking if there is an alternative to it, such as adding a UIView over the other views or a new component from the iPhone SDK.

Thanks.

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

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

发布评论

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

评论(2

迷荒 2025-01-05 22:02:03

看一下 FPPopover

代码真的很简单,有很多自动的东西

//the view controller you want to present as popover
YourViewController *controller = [[YourViewController alloc] init]; 

//our popover
FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller]; 

//the popover will be presented from the okButton view 
[popover presentPopoverFromView:okButton]; 

Take a look at FPPopover

The code is really simple and has a lot of automatic things

//the view controller you want to present as popover
YourViewController *controller = [[YourViewController alloc] init]; 

//our popover
FPPopoverController *popover = [[FPPopoverController alloc] initWithViewController:controller]; 

//the popover will be presented from the okButton view 
[popover presentPopoverFromView:okButton]; 
甜是你 2025-01-05 22:02:03

将目标添加到您的 UIBarButtonItem 中

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"button!" style:UIBarButtonItemStyleBordered target:self action: @selector(showPopover:)];

,并在您的目标中执行如下操作:

- (void)showPopover:(id)sender
{

    popoverController = [[[WEPopoverController alloc] initWithContentViewController:contentViewController] autorelease];
    [popoverController presentPopoverFromRect:sender.frame 
                                            inView:self.view 
                          permittedArrowDirections:UIPopoverArrowDirectionDown
                                          animated:YES];
}

此代码改编自 WEPopover https://github.com/werner77/WEPopover/blob/master/Classes/WEPopoverViewController.m

add a target to your UIBarButtonItem

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithTitle:@"button!" style:UIBarButtonItemStyleBordered target:self action: @selector(showPopover:)];

and in your target do something like this:

- (void)showPopover:(id)sender
{

    popoverController = [[[WEPopoverController alloc] initWithContentViewController:contentViewController] autorelease];
    [popoverController presentPopoverFromRect:sender.frame 
                                            inView:self.view 
                          permittedArrowDirections:UIPopoverArrowDirectionDown
                                          animated:YES];
}

this code was adapted from the sample provided with WEPopover https://github.com/werner77/WEPopover/blob/master/Classes/WEPopoverViewController.m

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