//當我們點擊某個cell時,會執(zhí)行下面這個方法,在方法中調(diào)用另一個方法 btnActionForUserSetting: 執(zhí)行具體的操作:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
if (0 == indexPath.section) {
[self btnActionForUserSetting: self.tableView];
???? }
}
//在下面方法中怎樣獲取剛剛選中的那個cell楚堤,并修改它的內(nèi)容呢?
- (void)btnActionForUserSetting:(id) sender {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath: indexPath];
cell.textLabel.text = @"abc";
}
這樣,被點擊的cell的內(nèi)容就被修改了交胚。
補充問題:以上方法只有在點擊cell時才能確定cell的index尺借,而如果點擊了cell上的button绊起,用上面的方法還是沒辦法解決。
解決辦法:由按鈕獲得它SuperView,即你自己定義的cell,知道這個cell了后在得到它的行數(shù)燎斩。