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

后端 未结 11 824
失恋的感觉
失恋的感觉 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:10

    In Swift, between the above answers this works for me on an iPad in any orientation:

    if let popOverPresentationController : UIPopoverPresentationController = myAlertController.popoverPresentationController {
    
        let cellRect = tableView.rectForRowAtIndexPath(indexPath)
    
        popOverPresentationController.sourceView                = tableView
        popOverPresentationController.sourceRect                = cellRect
        popOverPresentationController.permittedArrowDirections  = UIPopoverArrowDirection.Any
    
    }
    

提交回复
热议问题