AlertView
1、创建
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@”什么鬼” message:@”有毒” delegate:self cancelButtonTitle:@”确定” otherButtonTitles:nil, nil];
2、显示
[alertView show];
3、设置类型 alertViewStyle
alertView.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
4、获取输入框
UITextField *textField1 = [alertView textFieldAtIndex:0];
5、UIAlertViewDelegate
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@”%ld”,buttonIndex);
switch (buttonIndex) {
case 0:{
NSLog(@”确定”);
}
break;
case 1:{
UITextField *field = [alertView textFieldAtIndex:0];
NSLog(@”%@”,field.text);
NSLog(@”取消”);
}
break;
case 2:{
NSLog(@”取消1”);
}
break;
case 3:{
}
break;
}
}
ActionSheet
1、创建
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@”标题” delegate:self cancelButtonTitle:@”确定” destructiveButtonTitle:@”性别选择” otherButtonTitles:@”男”,@”女”, nil];
2、显示
[actionSheet showInView:self.view.window];
3、UIActionSheetDelegate
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@”%ld”,buttonIndex);
switch (buttonIndex) {
case 0:{
NSLog(@”性别选择”);
}
break;
case 1:{
NSLog(@"男");
}
break;
case 2:{
NSLog(@"女");
}
break;
case 3:{
NSLog(@"确定");
}
break;
}
}