cuốn sách gpt4 ai đã làm

ios - 使用 Swift 3 将数据从 Modal Viewcontroller 传递到 rootController(不要 Segue)

In lại Tác giả: Walker 123 更新时间:2023-11-28 08:11:02 30 4
mua khóa gpt4 Nike

我有一个问题。

我需要帮助。我一直在寻找解决方案大约 5 个小时。不幸的是没有成功。

我的问题是我有几个 Storyboard并且没有使用 Segue 创建。

我希望将选定的 Tableviewcell 标题传递给 rootViewController。

这是我在 ModalViewTable 中的代码:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
let indexNumber = "\(indexPath.row)"

let indexPath = tableView.indexPathForSelectedRow
let currentCell = tableView.cellForRow(at: indexPath!) as UITableViewCell!
let storyboard = UIStoryboard(name: "addTime", bundle: nil)
var viewController = storyboard.instantiateViewController(withIdentifier: "addTimeVC") as! addTimeViewController
viewController.test = "TESTABCDEF"
passedValue = ("\(indexNumber)")
dismiss(animated: true, completion: nil)
}

我的 firstViewController 中有一个属性 Bài kiểm tra。这里有什么问题?我也尝试过委托(delegate)和闭包,但没有成功。请帮我。

câu trả lời hay nhất

Hãy thử điều này:

let indexNumber = "\(indexPath.row)"
let indexPath = tableView.indexPathForSelectedRow
let currentCell = tableView.cellForRow(at: indexPath!) as UITableViewCell!

let viewController = navigationController!.presentingViewController as! addTimeViewController
viewController.test = "TESTABCDEF"
passedValue = ("\(indexNumber)")
navigationController!.dismiss(animated: true, completion: nil)

当您使用 present(_:animated) 方法以模态方式呈现 View Controller 时,呈现 的 View Controller 具有 presentingViewControllerThuộc tính được đặt thành呈现它的 View Controller 。换句话说,此属性包含对先前 View Controller 的引用。

关于ios - 使用 Swift 3 将数据从 Modal Viewcontroller 传递到 rootController(不要 Segue),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43792315/

30 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress