對於iOS,其實你不能老是
你可以看到TiUIAlertDialogProxy.m
https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiUIAlertDialogProxy.m#L164
代碼沒有TextField
值
if ((style == UIAlertViewStylePlainTextInput) || (style == UIAlertViewStyleSecureTextInput)) {
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.secureTextEntry = (style == UIAlertViewStyleSecureTextInput);
textField.placeholder = [TiUtils stringValue:[self valueForKey:@"placeholder"]] ?: @"";
textField.keyboardType = [TiUtils intValue:[self valueForKey:@"keyboardType"] def:UIKeyboardTypeDefault];
textField.returnKeyType = [TiUtils intValue:[self valueForKey:@"returnKeyType"] def:UIReturnKeyDefault];
textField.keyboardAppearance = [TiUtils intValue:[self valueForKey:@"keyboardAppearance"] def:UIKeyboardAppearanceDefault];
}];
}
,但你可以手動使它,請添加代碼
textField.text = [TiUtils stringValue:[self valueForKey:@"text"]] ?: @"";
然後通過text
財產
var dialog = Ti.UI.createAlertDialog({
text:'Init text',
title: 'Enter text',
style: Ti.UI.iOS.AlertDialogStyle.PLAIN_TEXT_INPUT,
buttonNames: ['OK']
});