在表视图中的accessoryButtonTapped时导航到anotherview

时间:2014-02-27 06:43:09

标签: ios uitableview

我有一个表格视图,当我点击时我正在使用附件按钮我想要导航到其他视图控制器。我这样做了:

-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{    
    DateViewController *objDateViewController = [[DateViewController alloc]initWithNibName:@"DateViewController" bundle:nil];
    [self.navigationController pushViewController:objDateViewController animated:YES];

}

但它不起作用。请帮忙。

2 个答案:

答案 0 :(得分:2)

试试这个

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ...

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

    [button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
    ...
    cell.accessoryView = button;

    return cell;
}


- (void)checkButtonTapped:(id)sender {

}

答案 1 :(得分:0)

  1. 检查您的委托方法是否被触发?

  2. viewcontroller

  3. 中有navigationcontroller(表格视图所在的位置)