- (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];
}