Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在TableView协议之外更改UITableViewCell.detailTextLabel_Iphone_Uitableview_Tableview - Fatal编程技术网

Iphone 在TableView协议之外更改UITableViewCell.detailTextLabel

Iphone 在TableView协议之外更改UITableViewCell.detailTextLabel,iphone,uitableview,tableview,Iphone,Uitableview,Tableview,我有一个有3个单元格的桌面视图 我想在加载tableView后更改该单元格的.detailTextLabel 我怎么能做到 我认为: UITableViewCell*firstCell=[tableView cellForRowAtIndexPath:0] firstCell.detailTextLabel.text=@“ABC” [tableView重新加载数据] 但这并不是什么都不做。有什么问题吗?试试这个: UITableViewCell *firstCell = [tableView c

我有一个有3个单元格的桌面视图

我想在加载tableView后更改该单元格的.detailTextLabel

我怎么能做到

我认为:

UITableViewCell*firstCell=[tableView cellForRowAtIndexPath:0]

firstCell.detailTextLabel.text=@“ABC”

[tableView重新加载数据]

但这并不是什么都不做。有什么问题吗?

试试这个:

UITableViewCell *firstCell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];

firstCell.detailTextLabel.text = @"ABC";
无需调用重载数据。

而不是

UITableViewCell *firstCell = [tableView cellForRowAtIndexPath:0];
使用

当你说

[tableView重新加载数据]

当时你的:

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

方法将被调用三次,因为行中有3个单元格,这将再次使用必须通过数组提供的原始文本覆盖firstCell.detailTextLabel.text

因此,如果您使用的是数组。。然后需要更改该数组中的对象以获得所需的索引

只要实现这一点:

[数组替换对象索引:0,对象:@“更改”]

[tableViewCategory重新加载数据]


希望这对您有用…

您对[tableView reloadData]发表评论了吗;以及更改detailTextLabel的位置,因为如果在调用tableview委托方法之前进行更改,则cellForRowAtIndexPath将覆盖您的值。我在调用tableview委托方法之后调用它。
UITableViewCell *firstCell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];