How to refresh UITableViewCell?

前端 未结 3 393
别跟我提以往
别跟我提以往 2021-02-03 13:01

I have a UITableView with a custom UITableViewCell. In cellForRowAtIndexPath, I assign a font to a label in every cell, since the user can change font size at any time. To cha

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-03 13:27

    I'm curious, how do you display your settings screen? viewWillAppear should be called under normal circumstances when returning. Do you use

    [self presentModelViewController:animated:]
    

    or

    [self.navigationController pushViewController:animated:]
    

    These should both work. If, on the other hand, you're just adding the settings view as a subview of the window or current view or something, then removing it won't call viewWillAppear on the table view controller.

    So if you're not using one of those two methods, do. If you already are, then setting the font of the cell is really as simple as getting the cell and setting its font. If you're using a standard UITableViewCell, that's done with

    cell.font = newFont;
    

    If you're using a custom subclass, I obviously can't tell you exactly how it needs to work, but the way Nikolai has it is correct.

提交回复
热议问题