Search code examples
objective-cipaduipopovercontrollerpopover

How to correctly present a popover from a UITableViewCell with UIPopoverArrowDirectionRight or UIPopoverArrowDirectionLeft


I always try to present a popover from a cell inside a tableView this way:

[myPopover presentPopoverFromRect:cell.frame inView:self.tableView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

but I cannot use UIPopoverArrowDirectionRight or Left, because, depending on the position of the ipad (portrait or landscape), the popover appears someplace else.

Am I presenting the popover the right way?

PS: the table view is in the detailView of a splitView.


Solution

  • Here is the simple solution which works fine for me

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        CGRect rect=CGRectMake(cell.bounds.origin.x+600, cell.bounds.origin.y+10, 50, 30);
        [popOverController presentPopoverFromRect:rect inView:cell permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    
    }