Is it possible to perform a Popover Segue manually (from dynamic UITableView cell)?

后端 未结 4 853
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 01:09

I need to perform a Popover segue when user touches a cell in a dynamic TableView. But when I try to do this with this code:

- (void)tableView:(UITableView *         


        
4条回答
  •  眼角桃花
    2020-12-14 01:34

    Swift answer using popoverPresentationController: Using storyboard, set up the new view controller with a Storyboard ID of popoverEdit.

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    
        let fromRect:CGRect = self.tableView.rectForRowAtIndexPath(indexPath)
    
        let popoverVC = storyboard?.instantiateViewControllerWithIdentifier("popoverEdit") as! UIViewController
        popoverVC.modalPresentationStyle = .Popover
        presentViewController(popoverVC, animated: true, completion: nil)
        let popoverController = popoverVC.popoverPresentationController
        popoverController!.sourceView = self.view
        popoverController!.sourceRect = fromRect
        popoverController!.permittedArrowDirections = .Any
    
    }
    

提交回复
热议问题