将indexPathForSelectedRow从一个VC传递到另一个VC的最佳方法是什么?

时间:2017-12-27 12:53:13

标签: ios swift uitableview indexpath

我试图访问IndexPath所选单元格的UITableView,但它不在同一个ViewController中。我怎样才能做到这一点?

 func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {

    mainTable.selectRow(at: indexPath, animated: true, scrollPosition: UITableViewScrollPosition.none)
    let popController = UIStoryboard(name: "Maina", bundle: nil).instantiateViewController(withIdentifier: "popoverId") as! SidePopOverViewController


    popController.modalPresentationStyle = UIModalPresentationStyle.popover

    popController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.left
    popController.popoverPresentationController?.delegate = self
    popController.popoverPresentationController?.sourceView = mainTable.cellForRow(at: mainTable.indexPathForSelectedRow!)
    popController.popoverPresentationController?.sourceRect = (mainTable.cellForRow(at: mainTable.indexPathForSelectedRow!)!.bounds)

    self.present(popController, animated: true, completion: nil)    
}


func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {  
    return UIModalPresentationStyle.none
}

0 个答案:

没有答案