Reputation: 153
is it possible to use a UISegmentedController to determine the key board type is available to the user? For example I want the user to have a numeric keyboard if one segment is activated and the default keyboard when the other segment is activated:
if (self.segmentController.selectedSegmentIndex == 1)
{
NSLog(@"Seg1");
[self.myTextField becomeFirstResponder];
[self.myTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
//enter numbers
[self resignFirstResponder];
[self.myTextField reloadInputViews];
}
else if (self.segmentController.selectedSegmentIndex == 0)
{
NSLog(@"seg0");
[self.myTextField becomeFirstResponder];
[self.myTextField setKeyboardType:UIKeyboardTypeDefault];
// enter words
[self resignFirstResponder];
[self.myTextField reloadInputViews];
}
Im sure Im missing something. Can anyone help?
Thanks
Upvotes: 1
Views: 64
Reputation: 12106
Try setting the type before you display the keyboard.
Change:
[self.myTextField becomeFirstResponder];
[self.myTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
To:
[self.myTextField setKeyboardType:UIKeyboardTypeNamePhonePad];
[self.myTextField becomeFirstResponder];
Upvotes: 1