Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@dbankier dbankier commented Jan 23, 2013

@yomybaby

This comment has been minimized.

Copy link

@yomybaby yomybaby commented Jan 24, 2013

Great! Thanks!

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