Ios 分区中tableViewCells中的图像(swift 3-Xcode 8.3.2)

Ios 分区中tableViewCells中的图像(swift 3-Xcode 8.3.2),ios,uitableview,swift3,intersection,Ios,Uitableview,Swift3,Intersection,嗨,我有一个表视图,想让它像下面的图片 这是我使用的代码(问题是我看不到每个单元格的图片: var menuImage = ["Add.png" , "Menu.png" , "Add.png" , "Add.png" , "Add.png" , "Add.png" ] func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell

嗨,我有一个表视图,想让它像下面的图片

这是我使用的代码(问题是我看不到每个单元格的图片:

var menuImage = ["Add.png" , "Menu.png" , "Add.png" , "Add.png" , "Add.png" , "Add.png" ]

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = UITableViewCell()
    cell.textLabel!.text = listSetting[indexPath.section][indexPath.row]
    cell.preservesSuperviewLayoutMargins = false
    cell.separatorInset = UIEdgeInsets.zero
    cell.layoutMargins = UIEdgeInsets.zero
    cell.textLabel?.textAlignment = .right
    cell.textLabel?.font = UIFont.init(name: "IRANSans", size: 14)
    cell.imageView?.image = UIImage.init(named: menuImage[indexPath.row])

    return cell

}
第二个问题是我想检测哪些单元格被按下这里是我使用但不起作用的代码:

func tableView(_ tableView: UITableView, didSelectRowAt listSetting: IndexPath) {

        print("Remove Adds")


        if listSetting.section == 1 && listSetting.row == 1{
            //Code to implement View Controller to remove adds
            print("Cell4 pressed")
        }

打开Main.storyboard,选择单元格,并在“大小检查器”中将行高度更改为140(根据您的需要检入故事板) 现在,在viewDidLoad()中键入以下代码,使用UITableViewAutomaticDimension方法:

tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 140 //as per your need 
并提到这个重载数据()

更多结帐链接如下:


我可以看到您在UITableView中使用了4-5个节。您需要在菜单图像数组中设置数组数组,以便使用UITableView节和行数填充图像我在节和行中使用了数组(我的代码非常大,因此我在这里写了一些代码)但是我有两个数组,一个用于节,另一个用于单元格var listSetting=[[“A”,“B”],[“C”,“D”,“E”],[“F”]]
self.tableView.reloadData()