代码十分简单,不需要重写什么的,
直接上源码:
-(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);
}
}
效果图:
转载请注明原文地址: https://ju.6miu.com/read-1126294.html