2010-10-22 41 views
1

我想以編程方式在我的UITableView中設置文本。我不想從在tableView中設置文本

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

做到這一點我想是這樣

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

這不起作用,因爲這不是結構的一部分。我該怎麼做?一直在尋找文檔,但無法找到它。

+0

爲什麼你不想在cellForRowAtIndexPath方法中做到這一點? – Anna 2010-10-22 02:45:17

+0

我想加載我的tableView與來自ABPeoplePickerNavigationControllerDelegate的數據。所以我認爲從ABPeoplePickerNavigationControllerDelegate設置我的tableView.textField.text很容易。 – munchine 2010-10-22 02:56:49

+0

現在無法給出詳細的答案,但是您應該將從ABPeoplePicker獲取的數據放入某個對象X並在cellForRowAtIndexPath中讀取該對象。在ABPeoplePicker完成後,您可以在表視圖上調用reloadData以使其顯示更新的數據。 – Anna 2010-10-22 03:05:43

回答

0

你想使用textLabel,而不是textField。總的來說,這是一個糟糕的主意。您應該在-tableView:cellForRowAtIndexPath:中提供適當的單元格。如果你只想調整一個單元格,你可以使用 - [UITableView reloadRowsAtIndexPaths:withRowAnimation:]。

+0

你是對的這是一個非常糟糕的主意。正確的方法正如aBitObvious所建議的。 – munchine 2010-10-22 04:24:57