Skip to content

Instantly share code, notes, and snippets.

@dbankier
Last active March 17, 2016 06:12
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dbankier/4615745 to your computer and use it in GitHub Desktop.
Save dbankier/4615745 to your computer and use it in GitHub Desktop.
Adds `keyboardType` and `hintText` to PLAIN_TEXT_INPUT AlertDialog
// So you can do this:
var dialog = Ti.UI.createAlertDialog({
title: "Business Number",
style: Ti.UI.iPhone.AlertDialogStyle.PLAIN_TEXT_INPUT,
keyboardType: Ti.UI.KEYBOARD_PHONE_PAD,
hintText: "Enter Phone Number",
buttonNames: ['OK']
});
// For SDK 3.0.0 modify TiUIAlertDialogProxy.m at around line 124 to look like this:
if ([TiUtils isIOS5OrGreater])
{
int style = [TiUtils intValue:[self valueForKey:@"style"] def:UIAlertViewStyleDefault];
[alert setAlertViewStyle:style];
if (style == UIAlertViewStylePlainTextInput) {
int keyboardType = [TiUtils intValue:[self valueForKey:@"keyboardType"] def: UIKeyboardTypeDefault];
NSString *hintText = [TiUtils stringValue:[self valueForKey:@"hintText"]];
UITextField *alertTextField = [alert textFieldAtIndex:0];
alertTextField.keyboardType = keyboardType;
alertTextField.placeholder = hintText;
}
}
@dbankier
Copy link
Author

@yomybaby
Copy link

Great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment