如何在 iPhone 中单击按钮时显示 UIPopoverController

发布于 2024-12-17 19:59:24 字数 742 浏览 2 评论 0原文

我的 UIPopoverController 有问题。按下按钮时我需要显示 UIPopoverController。这是代码。

-(IBAction)hintButton:(id)sender{ 
CGRect contentRect = CGRectMake(0, 0, 200, 40);
UIViewController* popoverContent = [[UIViewController alloc] init];
popoverContent.view = hintB;

popoverContent.contentSizeForViewInPopover = contentRect.size;
if(popoverController == nil){   //make sure popover isn't displayed more than once in the view
    popoverController = [[UIPopoverController alloc]initWithContentViewController:popoverContent]; 

    [popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    popoverController.delegate = self;
 }  

当我按下按钮时,应用程序崩溃

I have a problem with UIPopoverController. On button press I need to display the UIPopoverController. This is the code.

-(IBAction)hintButton:(id)sender{ 
CGRect contentRect = CGRectMake(0, 0, 200, 40);
UIViewController* popoverContent = [[UIViewController alloc] init];
popoverContent.view = hintB;

popoverContent.contentSizeForViewInPopover = contentRect.size;
if(popoverController == nil){   //make sure popover isn't displayed more than once in the view
    popoverController = [[UIPopoverController alloc]initWithContentViewController:popoverContent]; 

    [popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    popoverController.delegate = self;
 }  

}

When I press the button application crashes.

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

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

发布评论

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

评论(1

千年*琉璃梦 2024-12-24 19:59:24

UIPopoverController 不能用于 iPhone 应用程序。它仅适用于 iPad 应用程序。

但是,您可以通过创建自定义 UIPopoverController 来拥有此功能。您可以在此处找到自定义 UIPopoverController 示例。

如果您有任何类似问题,请告诉我。

谢谢,

米努大师

UIPopoverController cannot be used for iPhone applications. It's only for iPad apps.

However, you can have this functionality by creating custom UIPopoverController. You can find a custom UIPopoverController sample here.

Let me know if you have any similar questions.

Thanks,

MinuMaster

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