ios——带文本框的alertView

来源:互联网 发布:机器聊天软件 编辑:程序博客网 时间:2024/06/05 07:05

代码十分简单,不需要重写什么的,

直接上源码:

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"测试" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];//初始化一个alertView    [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];//setAlertViewStyle    [alertView show];}//alertView的代理方法- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{    if (buttonIndex == 1) {        UITextField *evaluate = [alertView textFieldAtIndex:0];//获取alertView的文本框        NSLog(@"%@",evaluate.text);    }}

效果图:



1 0
原创粉丝点击