开发者

setting text in tableView

开发者 https://www.devze.com 2023-01-20 17:14 出处:网络
I want to programatically set a text in my UITableView. I do not want to do it from - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

I want to programatically set a text in my UITableView. I do not want to do it from

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

I tried something like

[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].textField.text = @"te开发者_C百科st";

This doesn't work as this is not part of the structure. How do I do it? Been looking in the docs but cannot find it.


You want to use textLabel, not textField. This is, in general, a bad idea. You should provide the proper cell in -tableView:cellForRowAtIndexPath:. If you only want to adjust one cell, you can use -[UITableView reloadRowsAtIndexPaths:withRowAnimation:].

0

精彩评论

暂无评论...
验证码 换一张
取 消