Popover segue to static cell UITableView causes compile error

lehn0058 picture lehn0058 · Sep 1, 2012 · Viewed 6.9k times · Source

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>>

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...

Answer

lehn0058 picture lehn0058 · Sep 3, 2012

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];
}

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.