Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.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中设置文本_Iphone_Uitableview_Textfield - Fatal编程技术网

Iphone 在tableView中设置文本

Iphone 在tableView中设置文本,iphone,uitableview,textfield,Iphone,Uitableview,Textfield,我想在UITableView中以编程方式设置文本。我不想从一开始就这样做 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 我试过类似的东西 [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].textField.text

我想在UITableView中以编程方式设置文本。我不想从一开始就这样做

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
我试过类似的东西

[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].textField.text = @"test";

这不起作用,因为这不是结构的一部分。我该怎么做?已在文档中查找,但找不到它。

您想使用textLabel,而不是textField。总的来说,这是个坏主意。您应该在-tableView:cellforrowatinexpath:中提供适当的单元格。如果只想调整一个单元格,可以使用-[UITableView ReloaderRowsatindExpaths:withRowAnimation:]。

为什么不想在cellForRowAtIndexPath方法中进行调整?我想用ABPeoplePickerNavigationControllerDelegate中的数据加载我的tableView。因此,我认为从ABPeoplePickerNavigationControllerDelegate设置tableView.textField.text很容易。现在无法给出详细答案,但您应该将从ABPeoplePicker获得的数据放入某个对象X中,并在cellForRowAtIndexPath中读取该对象。完成ABPeoplePicker后,可以在表视图上调用reloadData,使其显示更新的数据。你是对的,这是一个非常糟糕的主意。正确的方法正如Abitobevious所建议的那样。