我已经得到了从试图找到一个答案,这也太沮丧,所以我会为一个问题...从UIAlertView中文本框中输入提取的Objective-C
如何从一个UIAlertView中获得的原始文本Objective-C中的文本框?
这里是我的代码:
UIButton *AppCrashButton = [UIButton buttonWithType: UIButtonTypeCustom];
AppCrashButton.frame = CGRectMake(0, (self.view.frame.size.height - 44)/6 * 1, self.view.frame.size.width, (self.view.frame.size.height - 44)/6);
[AppCrashButton setTitle: @"Ping" forState: UIControlStateNormal];
[AppCrashButton addTarget: self action: @selector(Click) forControlEvents: UIControlEventTouchUpInside];
AppCrashButton.backgroundColor = [UIColor colorWithRed:0.19 green:0.19 blue:0.19 alpha:1.0];
AppCrashButton.layer.borderColor = [UIColor colorWithRed:0.96 green:0.26 blue:0.21 alpha:1.0].CGColor;
AppCrashButton.layer.borderWidth = 0.5f;
[self.view addSubview: AppCrashButton];
-(void) Click {
UIAlertView *AppCrashAlert = [[UIAlertView alloc] initWithTitle: @"IP Ping" message: @"Please enter the IP address" delegate: self cancelButtonTitle: @"Cancel" otherButtonTitles: @"OK", nil];
AppCrashAlert.alertViewStyle = UIAlertViewStylePlainTextInput;
[AppCrashAlert show];
[AppCrashAlert release];
}
它显示了一个自定义按钮,一旦点击,执行“点击”的方法,其中执行ping主机。
我想知道如何从文本输入中获取文本。
感谢
仅供参考 - 'UIAlertView'被弃用早在iOS版8.您应该使用'UIAlertController'。 – rmaddy