我必須得到IndexPath值到NSMutableArray。當一個特定的單元格被選中時,我必須做一個操作它的IndexPath存儲在NSMutableArray中,並且特定的單元格高度正在增加。當我再次按下那個單元格時,特定的單元格高度正在下降。我怎麼可能以及我必須提出什麼樣的條件?如何獲得indexPath值到NSMutableArray?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"%@",indexPath);
selectIndexPathCell = indexPath;
NSIndexPath *previousSelectedIndexPath = selectIndexPathCell;
selectIndexPathCell = indexPath;
if (previousSelectedIndexPath) {
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:previousSelectedIndexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:selectIndexPathCell]
withRowAnimation:UITableViewRowAnimationAutomatic];
self.selectedRow = sections_main[indexPath.section][@"content"][indexPath.row];
[tblPeople beginUpdates];
[tblPeople endUpdates];
}
- (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(selectIndexPathCell != nil && [selectIndexPathCell compare:indexPath] == NSOrderedSame){
return 80;
}else{
return 60.0;
}
}
我應該在heightForRowAtIndexPath中寫什麼?是否有任何代碼檢查或其他 – Ankit
@Ankit請參閱我已更新它的回答 –
仍然無法在我的代碼中工作。 – Ankit