IOS 中UIAlertView中获取自定义文本框文字方法

来源:互联网 发布:易语言编程招聘 编辑:程序博客网 时间:2024/06/06 11:43

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"保存到" message:@"我的收藏" delegate:selfcancelButtonTitle:@"保存" otherButtonTitles:@"取消", nil];    alert.alertViewStyle = UIAlertViewStylePlainTextInput;    UITextField *textField = [alert textFieldAtIndex:0];    textField.keyboardType = UIKeyboardTypeDefault;    [alert addSubview:textField];    [alert show];    [alert release];

如图:

IOS <wbr>中UIAlertView中获取自定义文本框文字方法

实现代理方法

 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ for (UIView *view in [alertView subviews])                 {            if ([view isKindOfClass:[UITextField class]]){                UITextField *textName = (UITextField *)view;                NSLog(@"%@",textName.text);            }        }}
转自:http://blog.sina.com.cn/s/blog_94103cd90101c6d3.html

原创粉丝点击