Popover segue到静态单元格UITableView会导致编译错误 [英] Popover segue to static cell UITableView causes compile error

查看:106
本文介绍了Popover segue到静态单元格UITableView会导致编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个带有两个视图控制器的应用程序。第一个是具有嵌入式表视图的视图控制器,该视图控制器具有动态单元。第二个是带有静态单元的表视图控制器。如果我从选择动态表格的一个单元格到静态表格视图控制器(使用Push或Modal样式设置)添加一个segue,我可以看到segue按预期工作。但是,当我将样式更改为Popover时,我得到以下编译错误:

I currently have an application with two view controllers. The first is a view controller with an embedded table view that has dynamic cells. The second is a table view controller with static cells. If I add a segue from selecting one of the dynamic table's cells to the static table view controller (using the Push or Modal style setting), I can see that the segue works as expected. However, when I change the style to Popover I get the following compile error:

Couldn't compile connection: <IBCocoaTouchOutletConnection:0x4004c75a0 <IBProxyObject: 0x400647960> => anchorView => <IBUITableViewCell: 0x400f58aa0>>

是否有其他人遇到此问题,或者有人知道此错误消息可能意味着什么?在编译时发生这种情况似乎很奇怪,除非Popover不支持静态表视图控制器...

Has anyone else ran into this issue, or does anyone know what this error message might mean? It seems strange that this is happening at compile time unless a static table view controller is not supported in a Popover...

推荐答案

我想出了如何做到这一点。你无法从故事板上挂起它,但可以这样编程:

I figured out how to do this. You can't hook it up from the storyboard but can do it programmatically like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad"
                                                 bundle:nil];
    UITableViewController *detailController = [sb instantiateViewControllerWithIdentifier:@"TableSettingDetails"];

    self.popoverController = [[UIPopoverController alloc] initWithContentViewController:detailController];

    self.popoverController.popoverContentSize = CGSizeMake(320, 416);
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    [self.popoverController presentPopoverFromRect:cell.bounds inView:cell.contentView
                          permittedArrowDirections:UIPopoverArrowDirectionAny
                                          animated:YES];
}

请确保您在控制器中有对popover的引用,否则它将立即被处置 - 引起一些其他有趣的例外。

Just make sure that you have a reference to your popover in your controller, otherwise it will get immediately disposed - causing some other interesting exceptions.

这篇关于Popover segue到静态单元格UITableView会导致编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆