1

when i use the method to reload my cell , it cause a little bug

self.tableView.reloadRows(at: [indexPath], with: .none)

if i use such to close the animation ,it works ok

UIView.performWithoutAnimation {
    self.tableView.reloadRows(at: [indexPath], with: .none)
}

the demo and the git address https://github.com/yuandiLiao/TestTabeviewReload/tree/master

you can see the bug show in the github .And the controller code like this . thanks guys

class SecondViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
    var tableView:UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()
        let tableview = UITableView(frame: self.view.bounds, style: .grouped)
        tableview.delegate = self
        tableview.dataSource = self
        tableview.register(TestTableViewCell.self, forCellReuseIdentifier: NSStringFromClass(TestTableViewCell.self))
        tableview.estimatedRowHeight = 0
        self.view.addSubview(tableview)
        self.tableView = tableview

    }

    func numberOfSections(in tableView: UITableView) -> Int {
        return 6
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        if section == 0{
            return 1
        }
        if section == 1 {
            return 0
        }
        return 10
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 120
    }

    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 50
    }
    func tableView(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat {
        return 5
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let header = UILabel()
        header.text = "section" + String(section)
        return header
    }
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let footer = UIView()
        footer.backgroundColor = UIColor.orange
        return footer
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: NSStringFromClass(TestTableViewCell.self)) as! TestTableViewCell
        cell.tag = Int(String(indexPath.section + 1) + String(indexPath.row))!
        cell.textLabel?.text = "cell" + String(indexPath.section) + String(indexPath.row)
        return cell
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        self.tableView.reloadRows(at: [indexPath], with: .none)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

thanks

廖源迪
  • 23
  • 4
  • What is your question? If you want to write a bug report this is not a good place. – OOPer Sep 01 '18 at 06:16
  • the bug show in demo . i want to know how to fix it .for now ,i do not Why does this cause this problem? thanks – 廖源迪 Sep 01 '18 at 09:23
  • You may need the statement in the text of your question. Also you should better include some relevant codes. Not many readers dig deep inside the linked repository. – OOPer Sep 01 '18 at 09:52
  • Add some code to your question. I don't like going to Github to download a random repo to run on my computer. That's a huge security risk. – Code Different Sep 01 '18 at 14:04
  • I had add UIViewController code ,and the problem you can see the gif in the Github . thanks guys – 廖源迪 Sep 01 '18 at 23:07

0 Answers0