我有一个表格视图,当点击它时我正在使用附件按钮,我想导航到其他视图控制器。我已经做到了:
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
DateViewController *objDateViewController = [[DateViewController alloc]initWithNibName:@"DateViewController" bundle:nil];
[self.navigationController pushViewController:objDateViewController animated:YES];
}
但它不起作用。请帮忙。
最佳答案
尝试这个
- (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 {
}