小编Meh*_*l D的帖子

如何使用委托从 Tableview 单元格内的 Collectionview 单元格导航到另一个 ViewController?

我正在尝试从 Tableview 单元格内的 Collectionview 单元格导航到另一个 ViewController。

我试图使用委托方法来实现,但它没有导航到预期的视图控制器。

这是我迄今为止开发的代码。我在这里使用 xib 设置。

//  ViewController.swift

import UIKit

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate,CustomTableViewCellDelegate {

    @IBOutlet weak var tableView: UITableView!
    var customTableViewCell = CustomTableViewCell()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        customTableViewCell.delegate = self
        
        tableView.delegate = self
        tableView.dataSource = self
        
        self.tableView.register(UINib(nibName: "CustomTableViewCell", bundle: nil), forCellReuseIdentifier: "CustomTableViewCell")
    }

    override func viewWillAppear(_ animated: Bool) {
        navigationController?.navigationBar.barTintColor = UIColor.black
        navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
        self.navigationController?.navigationBar.tintColor = UIColor(red: 211/255, green: 86/255, blue: 50/255, …
Run Code Online (Sandbox Code Playgroud)

uitableview ios appdelegate uicollectionview swift

1
推荐指数
1
解决办法
717
查看次数

标签 统计

appdelegate ×1

ios ×1

swift ×1

uicollectionview ×1

uitableview ×1