Objective c 如何在ipad中点击tableview单元格显示popover

Objective c 如何在ipad中点击tableview单元格显示popover,objective-c,ipad,uipopovercontroller,Objective C,Ipad,Uipopovercontroller,我在我的应用程序中使用一个TableView,当我点击一个选项卡单元格时,我想要一个弹出视图,表格单元格中的所有内容都应该显示在弹出视图中,所以请建议我怎么做 下面有一些示例代码不起作用。因此建议使用代码,我希望单元格中的所有内容都显示在弹出视图中 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIView *aView = [[UIView alloc]

我在我的应用程序中使用一个TableView,当我点击一个选项卡单元格时,我想要一个弹出视图,表格单元格中的所有内容都应该显示在弹出视图中,所以请建议我怎么做

下面有一些示例代码不起作用。因此建议使用代码,我希望单元格中的所有内容都显示在弹出视图中

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIView *aView = [[UIView alloc] init];
UIPopoverController *popoverController = [[UIPopoverController alloc] 
                                          initWithContentViewController:aView];
popoverController.popoverContentSize = CGSizeMake(320, 416);
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
[popoverController presentPopoverFromRect:cell.bounds inView:cell.contentView 
                 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
课程参考清楚地说明

要显示popover,请创建该类的实例并显示它 使用适当的方法之一。初始化的实例时 在该类中,必须提供提供 popover的内容。Popover的大小通常是从 查看它们所显示的控制器

popoverController应该有一个视图控制器,而不是视图

YourViewController *aViewController = [[YourViewController alloc] initWithNibName:nibName bundle:nil];
UIPopoverController *popoverController = [[UIPopoverController alloc] 
                                          initWithContentViewController:aViewController];
然后您可以显示此弹出窗口,您的代码很好,但是
您应该使用UIViewController而不是UIView。

您必须传递视图控制器而不是view

@7KV7:+1才能获得很好的答案..!:]@7KV7我应该在故事板中添加新的视图控制器吗?避免重复答案会更好,使站点更有效。请把类似的答案投上去,不要重复