使用此代碼展開表格視圖單元格,但它不適用於我。我知道這段代碼有一些錯誤幫助我找出答案。如何展開我的表格視圖單元格?
![selectindex = -1;
// Do any additional setup after loading the view.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return \[Arr_lbl count\];
}
#pragma mark table cell creating and loading the data
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
AntzclubCell *cell=\[tableView dequeueReusableCellWithIdentifier:@"Antz"\];
cell.img_antzClub.image=\[UIImage imageNamed:\[Arr_img objectAtIndex:indexPath.row\]\];
cell.lbl_antzClub.text=\[Arr_lbl objectAtIndex:indexPath.row\];
cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
cell.backgroundColor=\[UIColor blackColor\];
return cell;
}
#pragma mark expanding height
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(selectindex==indexPath.row){
return 400;
}
else{
return 132;
}
}
#pragma mark user selecting option
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row==selectindex) {
selectindex=-1;
\[tableView reloadRowsAtIndexPaths:\[NSArray arrayWithObject:indexPath\] withRowAnimation:UITableViewRowAnimationFade\];
return;
}
if(selectindex !=-1)
{
NSIndexPath *prepath=\[NSIndexPath indexPathForRow:selectindex inSection:0\];
selectindex=indexPath.row;
\[tableView reloadRowsAtIndexPaths:\[NSArray arrayWithObject:prepath\] withRowAnimation:UITableViewRowAnimationLeft\];
}
selectindex=indexPath.row;
\[tableView reloadRowsAtIndexPaths:\[NSArray arrayWithObject:indexPath\] withRowAnimation:UITableViewRowAnimationFade\];
}]
這個形象是我的輸出,而我單擊單元格與其他數據未擴大合併。
每一個細胞都具有不同的高度? –
是不同的高度,但現在我爲每個單元實現了相同的高度。 –
所以你可以使用外部API類,這是幫助你。你可以在你的應用程序中使用外部api類,或者在應用程序中複製外部api代碼。 –