0
如何在一個uitableview上使用3個不同的單元格?我現在有3個按鈕當我按下任何按鈕時,應該更改表格視圖的單元格。請幫助如何在一個表視圖中使用不同的單元格?
如何在一個uitableview上使用3個不同的單元格?我現在有3個按鈕當我按下任何按鈕時,應該更改表格視圖的單元格。請幫助如何在一個表視圖中使用不同的單元格?
在按鈕的操作方法中,保存點按哪個按鈕&重新加載要更改單元的行。
-(void)button1Tapped:(id)sender
{
self.buttonIndex = 1;
NSArray* arr = [[NSArray alloc] initWithObjects:self.indexPathOfConcernedCell, nil];
[self.tableView reloadRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationNone];
[arr release];
}
然後,在cellForRowAtIndexPath:
回報的小區中的一個在此基礎上的按鈕是pressed-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath == self.indexPathOfConcernedCell)
{
if(self.buttonIndex == 1)
{
Cell1* cell = (Cell1*) [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier1"];
if(cell == nil)
{
cell = [[[Cell1 alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"CellIdentifier1"] autorelease];
}
}
else if(self.buttonIndex == 2)
{
//do similar stuff
}
//do similar stuff for buttonIndex 3 here
}
}
else
{
//your regular stuff
}
return cell;
}
您可以通過3個不同的細胞是什麼意思? –