2012-05-26 138 views
0

我正在使用委託方法從子視圖獲取數據,並且想要在根視圖中動態編輯我的表。如何更新UITableView中的單元格?

所以我願做這樣的事情在我的viewWillAppear中的方法:

[myTable setCell:newCell atIndex:i]; 

我該怎麼辦?非常感謝

+0

可能重複[是否有可能刷新UITableView中的單個UITableViewCell?](http://stackoverflow.com/questions/4448321/is-it-possible-to-refresh-a-single-uitableviewcell-in -a-uitableview) –

回答

0

好了,終於我把它用:

[cellules beginUpdates]; 
[cellules reloadData]; 
[cellules endUpdates]; 

我用reloadData,因爲它是一個小的TableView(3個單元),用於大TableViews這應該是更好的:

– reloadRowsAtIndexPaths:withRowAnimation: 

無論如何感謝!

+0

很高興你知道了!如果單元格可見,您也可以在表格視圖上調用'cellForRowAtIndexPath:',然後修改該單元格的屬性或內容 - 您可能會注意到一些Xcode項目模板使用了這種方法。 – rickster

+0

是的,我用reloadData,因爲我有一個小的表視圖(只有3個單元格),但我當然應該使用cellForRowAtIndexPath。謝謝 ! – Rob

0

把你的代碼之間:

[myTable beginUpdates]; 
//your code 
[myTable setCell:newCell atIndex:i]; 
//your code end 
[myTable endUpdates]; 
+0

不,我的意思是,有沒有辦法更新我的單元看起來像這個函數? – Rob

相關問題