【发布时间】:2016-06-27 06:36:42
【问题描述】:
我试图显示从uialertview 的textfield 获得的一些文本,而不是将文本显示到UILabel 中。
我觉得很难,有人可以帮助我吗??
- (IBAction)buttonPressed1:(id)sender {
//http://useyourloaf.com/blog/uialertcontroller-changes-in-ios-8/
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Title" message:@"Hello Crazy" preferredStyle:UIAlertControllerStyleAlert];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField)
{
textField.placeholder = NSLocalizedString(@"Pet Name", @"Name");
}];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
[alert dismissViewControllerAnimated:YES completion:nil];
// self.labelText1.text = [NSString stringWithFormat:@"alert.textFields.firstObject"];
// self.labelText1.text = [NSMutableString stringWithString:@"alert.textFields.firstObject"];
self.labelText1.text = @" \?alert.textFields.firstObject\? ";
}];
[alert addAction:ok];
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];
}
在这里你可以看到我试图在self.labelText1.text 中显示文本,这里这个labeltext1 接受一个字符串,但我想显示从uialertview 的placeholder 获得的文本。请给我一些建议...
【问题讨论】:
标签: ios objective-c uilabel uialertview