UIAlertView添加textField

简介: UIAlertView添加textField
- (IBAction)Open:(id)sender {
    UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Enter Name" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add",nil]; 
    [dialog setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
    // Change keyboard type
    [[dialog textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeNumberPad];
    [[dialog textFieldAtIndex:1] setKeyboardType:UIKeyboardTypeNumberPad];
    [dialog show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if(buttonIndex == 1)
        NSLog(@"%@",[[alertView textFieldAtIndex:0]text]);
}
II
- (IBAction)Open:(id)sender {
   UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@" " delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定那个", nil];
    UITextField * nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
    [nameField setBackgroundColor:[UIColor whiteColor]];
    [alert addSubview:nameField];
    [alert show];
}
相关文章
|
Swift iOS开发
iPad上的ActionSheet
最近公司的应用要做iPad的适配,所以这两天一直在调整项目的大小。
|
iOS开发
UISearchBar去除背景
UISearchBar去除背景
151 0
UISearchBar去除背景
添加textField到tableviewheader
添加textField到tableviewheader
65 0
UIActionSheet,UIAlertView,UIAlertController的详细说明
UIActionSheet,UIAlertView,UIAlertController的详细说明
119 0
UIActionSheet,UIAlertView,UIAlertController的详细说明
|
数据安全/隐私保护
|
数据安全/隐私保护 iOS开发