0

我有一个自定义 UITableViewCell 类,并且自定义单元格中有一个图像按钮,该按钮链接回单元格类上的方法。触发此方法时,我想从弹出框内的情节提要中启动一个孤立的 UIViewController。我已经尝试了几种技术来做到这一点。如果我将 UIViewController 添加为原型单元上按钮的 segue,则 Interface Builder 将无法编译。有没有人有什么建议?

更新:我得到它与以下工作:

UITableView *tv = (UITableView *) self.superview;
UITableViewController *vc = (UITableViewController *) tv.dataSource;

UIStoryboard *storyboard = vc.storyboard;
UIViewController *actionView = [storyboard          
     instantiateViewControllerWithIdentifier:@"ActionView"];

popoverController = [[UIPopoverController alloc]
                                          initWithContentViewController:actionView];
popoverController.popoverContentSize = CGSizeMake(320, 416);

[popoverController presentPopoverFromRect:self.actionButton.bounds      
    inView:self.actionButton
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];  
4

1 回答 1

2

如果您正确识别了它,您应该能够使用instantiateViewControllerWithIdentifier:from来获取任何视图控制器。UIStoryboard(由于获取故事板引用的最简单方法是来自已经来自它的某个视图控制器,因此您可能希望单元格通知当前控制器执行此操作……这取决于您的对象是如何连接的。)

于 2012-11-21T23:06:45.297 回答