segue取得cell中的按钮点击的行号
cell中点击分为两种方式,点击行跳转到主功能界面,点击cell上的button跳转的编辑界面,那么如何在点击button的时候知道所点击行的行号呢?解决办法是给button绑定tag: // 自定义一个button UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(0, 0, 55, 25); btn.backgroundColor = [UIColor clearColor]; btn.tag = indexPath.row;// 给按钮绑定tag,好知道点击的是哪行 [btn setTitle:@"Edit" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(Edit:) forControlEvents:UIControlEventTouchUpInside]; cell.accessoryView = btn; 在事件方法中传递button: - (IBAction)Edit:(UIButton *)sender { // 执行sugue [self performSegueWithIdentifier:@"deviceList2edit" sender