2017-07-08 77 views

回答

0

您需要爲所選行存儲indexPath。你可以把條件放在cellForRow左右。

這裏是排序例如:

int selectedIndexPath; 

的.m

-(void)viewDidLoad 
    { 
      [super viewDidLoad]; 
      // So it won't show any select for the first time 
      selectedIndexPath = -1; 
      [tableView reloadData]; 
    } 

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     int currentRow = (int)indexPath.row; 
     if(currentRow == selectedIndexPath) 
     { 
      // Show your base cell 
     } 
     else 
     { 
      // Show detail cell 
     } 
    } 
    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     selectedIndexPath = (int)indexPath.row; 
     [tableView reloadData]; 

    } 
:在h文件

聲明變量

相關問題