alertView中添加输入文本框

来源:互联网 发布:破解linux系统root密码 编辑:程序博客网 时间:2024/05/22 04:46

UIAlertView * alerView = [[UIAlertViewalloc]initWithTitle:@"添加分组" message:nildelegate:selfcancelButtonTitle:@"取消"otherButtonTitles:@"添加",nil];

        alerView.alertViewStyle =UIAlertViewStylePlainTextInput;

        alerView.delegate = self;

        UITextField * newGroup = [[UITextFieldalloc]initWithFrame:CGRectMake(0,0, 100,20)];

        newGroup.tag = 1001;

        [alerView addSubview:newGroup];

        [alerView show];




#pragma mark UIAlertView delegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

 if (buttonIndex == 0) 

 NSLog(@"取消"); 

 }else if (buttonIndex == 1) 

 { 

 NSLog(@"确定"); 

 UITextField * textField = nil; textField = [alertView textFieldAtIndex:0]; newGroupName = textField.text; 

 }

}

0 0