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

后端 未结 11 823
失恋的感觉
失恋的感觉 2020-12-02 15:30

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

[myPopover presentPopoverFromRect:cell.frame inView:self.tableView permittedArrowD         


        
11条回答
  •  误落风尘
    2020-12-02 16:02

    I did come across this problem as well. A solution for me was to simply change the width of the rect returned by CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath :

    CGRect rect = [aTableView rectForRowAtIndexPath:indexPath];
    
    //create a 10 pixel width rect at the center of the cell
    
    rect.origin.x = (rect.size.width - 10.0) / 2.0; 
    rect.size.width = 10.0;  
    
    [self.addExpensePopoverController presentPopoverFromRect:rect inView:aTableView permittedArrowDirections:UIPopoverArrowDirectionAny  animated:YES]; 
    

    This create a rect centred inside the cell. This way, the popover has more chances of findind a good spot to position itself.

提交回复
热议问题