0

我正在尝试访问 的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
}
4

0 回答 0