如何在 iPhone 中单击按钮时显示 UIPopoverController
我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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