UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"System Info" message:@"Do you want to Delete?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Confirm", nil];
alertView.tag=tableViewCell.shopcartCellFrame.product.productId;
[alertView show];
别忘了实现代理:
#pragma UIAlertView 代理
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex==0){
}else{
LJShopCartProduct *shopCartProduct=[[LJShopCartProduct alloc]init];
for(LJShopCartProduct *product in self.products){
if(product.productId==alertView.tag){
shopCartProduct=product;
}
}
[LJShopCartData deleteShopCartProduct:shopCartProduct];
if([LJShopCartData getShopCartCount]==0){
LJEmptyShopCartController *addressVC=[[LJEmptyShopCartController alloc]init];
[self.navigationController pushViewController:addressVC animated:YES];
}
[self.tableView reloadData];
}
}