, , . (, , popover .
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
StackPropertiesTableViewController *stackPropertiesTableViewController = [[StackPropertiesTableViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:stackPropertiesTableViewController];
self.stackPropertiesPopoverController = [[UIPopoverController alloc] initWithContentViewController:navController];
[self.stackPropertiesPopoverController setDelegate:self];
TableViewCell *cell = (TableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
CGRect contentViewFrame = cell.contentView.frame;
CGRect popRect = CGRectMake(contentViewFrame.origin.x + contentViewFrame.size.width, contentViewFrame.size.height/2.0, 1, 1);
[self.stackPropertiesPopoverController presentPopoverFromRect:popRect inView:cell permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
}
, popover . UIPopoverControllerDelegate
- (void)popoverController:(UIPopoverController *)popoverController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView *__autoreleasing *)view
{
if (self.stackPropertiesPopoverController == popoverController)
{
NSIndexPath *itemPath = self.tableView.indexPathForSelectedRow;
if (itemPath)
{
TableViewCell *cell = (TableViewCell *)[self.tableView cellForRowAtIndexPath:itemPath];
if (cell)
{
CGRect contentViewFrame = cell.contentView.frame;
CGRect popRect = CGRectMake(contentViewFrame.origin.x + contentViewFrame.size.width, contentViewFrame.size.height/2.0, 1, 1);
*rect = popRect;
}
}
}
}