当警报视图显示时,我希望文本字段中已有现有文本。这是我的代码,我必须添加什么?
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
[dialog setAlertViewStyle:UIAlertViewStylePlainTextInput];
// Change keyboard type
[[dialog textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeDefault];
[dialog show];
答案 0 :(得分:2)
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
[dialog setAlertViewStyle:UIAlertViewStylePlainTextInput];
[[dialog textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeDefault];
[[dialog textFieldAtIndex:0]setText:@"Your string here"];
[dialog show];
答案 1 :(得分:1)
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
[dialog setAlertViewStyle:UIAlertViewStylePlainTextInput];
[[dialog textFieldAtIndex:0]setText:@"YourText"];
// Change keyboard type
[[dialog textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeDefault];
[dialog show];
答案 2 :(得分:-1)
我在黑暗中拍摄,但试试看
dialog.textfield.text = @“Blah blahddy blah”
把它放在[dialog show]
之前。