现在的位置: 首页 > 综合 > 正文

UIAlertView添加textField

2018年05月25日 ⁄ 综合 ⁄ 共 1011字 ⁄ 字号 评论关闭

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

}

【上篇】
【下篇】

抱歉!评论已关闭.