声明一个button后,对button进行实例化中添加addTarget:
UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(0.0, 0.0, tableView.frame.size.width, VIEW_HEIGHT(80.0f))];
btn.backgroundColor = ColorRGBAValue(32, 171, 220, 1);
btn.layer.cornerRadius = 10.0f;
[btn setTitle:@"提交" forState:UIControlStateNormal];
//btn.titleLabel.font = [UIFont systemFontOfSize:18.0];
[btn addTarget:self action:@selector(addBack:) forControlEvents:UIControlEventTouchUpInside];
[cell addSubview:btn];
- (void)addBack:(UIButton *)sender {
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"确定提交?" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles: @"确定",nil];
[myAlertView show];
}
//点击确定之后返回前一个页面, ......没有添加新的数据~~
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"buttonIndex is: %li",(long)buttonIndex);
switch (buttonIndex) {
case 0:
break;
case 1:
[self.navigationController popViewControllerAnimated:YES];
break;
default:
break;
}
}
这样子就可以实现了点击alert 中确定后进行操作。