我有一个tableView。我的tableView单元格有一个细节附件。我的问题:我怎么能推另一个视图控制器时,细节按钮是按下。当我按下单元格时,我的ViewController1打开。但当我点击单元格右边的小I时,我想要推送一个不同的视图控制器。我该怎么做呢?
就像DidSelectRow
需要将DidSelectRow
修改为accessoryButtonTappedForRowWithIndexPath
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
// if u using .Xib
yourviewcontrollerName *vie=[[yourviewcontrollerName alloc]init];
[self.navigationController pushViewController: vie animated:YES];
//// if u using storyboard
[self performSegueWithIdentifier:@"yoursequeName"
sender:self];
}
使用Xcode Storyboard从Table View Cell push到Detail View
使用下面的代码就可以了
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
// Push new View controller here
UIViewController *objVc=[[UIViewController alloc]init];
[self.navigationController pushViewController:objVc animated:YES]
}