您的位置:首页 > 产品设计 > UI/UE

ios UIAlertView

2015-09-06 18:07 417 查看
ios UIAlertView相关代码如下:

- (IBAction)clicked:(id)sender
{
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请输入球队名称" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
[alertView show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex==1) {
//得到用户输入的内容
NSString *teamName = [alertView textFieldAtIndex:0].text;

if (alertView.tag==0) {//添加
//创建Team对象
Team *t = [NSEntityDescription insertNewObjectForEntityForName:@"Team" inManagedObjectContext:self.app.managedObjectContext];
t.name = teamName;

}else{//编辑
self.editTeam.name = teamName;
}
[self.app saveContext];
//让tableView刷新显示
[self.tableView reloadData];
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: