How can I update/reload/refresh a section header view in a UITableView?

后端 未结 2 2302
故里飘歌
故里飘歌 2021-02-20 16:29

I\'m willing to change a specific header view of my UITableView when I click a row.

I\'ve read all posts about it yet. I tried \"reloadData\", \"setNeed

2条回答
  •  终归单人心
    2021-02-20 17:23

    Have you tried reloadRowsAtIndexPaths:withRowAnimation: where you set the row property of the NSIndexPath passed in as NSNotFound? So reloading just the header of section 3, for instance would look like

    NSIndexPath * headerIndexPath = [NSIndexPath indexPathForRow: NSNotFound section:3];
    [self.tableView reloadRowsAtIndexPaths:@[headerIndexPath] withRowAnimation: UITableViewRowAnimationAutomatic];
    

    I guarantee nothing, but I'm pretty sure it used to work before, because I used it a couple of times.

    But even if it works, it's still a hack that might get broken by Apple any time.

    edit

    Ok, never mind. I tried this with iOS 7 in Xcode 5 and for some reason, even with NSNotFound as the row number, it still reloads the whole sections (with all its cells). So this does not work any more, damn.

提交回复
热议问题