2017-05-08 97 views
-1

單擊單元格中的按鈕後,我想要移動到視圖控制器。我嘗試用點擊按鈕:單元格中的按鈕和移動視圖控制器

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
NSInteger rowOfCell = [indexPath row]; 
TwoParramCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TwoParramCell" forIndexPath:indexPath]; 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     NSDictionary *dic = [self.arrayGoodInfo objectAtIndex:indexPath.row]; 
     cell.delegate = self; 
     if (rowOfCell == 0) { 
      cell.btnSearch.hidden = NO; 
     } 
     cell.btnSearch.tag = indexPath.row; 
     [cell.btnSearch addTarget:self action:@selector(searchBtnClicked:) forControlEvents:UIControlEventTouchUpInside]; 
     cell.lblTitle.text = [dic objectForKey:@"stockModelName"]; 
     cell.isMeterial = @"NO"; 
     cell.txtContent.text = @""; 
     cell.txtContent.tag = indexPath.row; 
     if ([dic objectForKey:@"serial"]) { 
      cell.txtContent.text = [dic objectForKey:@"serial"]; 
     }else{ 
      cell.txtContent.text = @""; 
     } 
     return cell;} 

這裏是searchBtnClicked:

- (void)searchBtnClicked: (UIButton *) sender{ 
    if (sender.tag == 0){ 
     SearchSerialVC *searchVC = [[SearchSerialVC alloc] initWithNibName:@"SearchSerialVC" bundle:nil]; 
     [self.navigationController pushViewController:searchVC animated:YES]; 
     [VTService showToastWithText:@"Search Serial"]; 
    } 
} 

吐司節目,但不能推到搜索串行視圖控制器。這裏發生了什麼?請幫幫我。

+0

哪裏是'searchBtnClicked'嗎?你可以檢查'searchVC'嗎?它是'零'嗎? –

+0

searchBtnClicked'[cell.btnSearch addTarget:self action:@selector(searchBtnClicked :) forControlEvents:UIControlEventTouchUpInside];'在這裏。並且搜索VC不是零,我檢查其他VC和相同的結果。 – Rin

+0

爲什麼用Swift標記? – toddg

回答

1
  • Step1。註釋掉[VTService showToastWithText:@"Search Serial"];
  • Step2。檢查self.navigationController
  • Step3。檢查SearchSerialVC

self.navigationController可能是零

+0

謝謝你,self.navigationController是無 – Rin

+0

@Rin也許你應該編輯你的標題。有沒有錯誤的'TableView'或'單元格中的按鈕。 – zippo

相關問題