2011-08-18 58 views

回答

0

在按鈕的操作方法中,保存點按哪個按鈕&重新加載要更改單元的行。

-(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; 

    } 
相關問題