Reputation: 1265
I have narrowed this down to only IOS6 devices.
Original Question:
I have searched everywhere and tried everything and I simply cannot figure this out!
I have a UITextField
. When it is selected, the keyboard slides up and the curser begins blinking on the textfield. When I tap the buttons on the keyboard everything behaves normally, the key responds and the curser stops blinking as it should. The only thing is that text is not put into the textfield! It does however accept input from the emoji keyboard. Any help will be very much appreciated!
This is how the UITextField
is created:
UITextField *userInput = [[UITextField alloc] initWithFrame:CGRectMake(10, yPos, controlWidth, 26)];
yPos += 32;
[userInput setText:[prompt defaultValue]];
[userInput setPlaceholder:[prompt helpText]];
[userInput setBorderStyle:UITextBorderStyleRoundedRect];
[userInput setClearButtonMode:UITextFieldViewModeWhileEditing];
[userInput setFont:[UIFont fontWithName:@"Helvetica" size:18]];
[userInput setAdjustsFontSizeToFitWidth:YES];
[userInput setMinimumFontSize:10];
[userInput setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[userInput setDelegate:self];
[self.scrollView addSubview:userInput];
[self.promptControls addObject:userInput];
[userInput release];
This is in a for loop so the number of UITextField
s depends on how many times the loop is called.
These are the delegate methods I use:
- (void)textFieldDidBeginEditing:(UITextField *)aTextField
{
self.activeField = aTextField;
}
- (void)textFieldDidEndEditing:(UITextField *)aTextField
{
self.activeField = nil;
}
- (BOOL)textFieldShouldReturn:(UITextField *)aTextField
{
[aTextField resignFirstResponder];
return YES;
}
activeField
is a property on the view controller just to determine which field is currently active
I believe that is all the relevant code
Upvotes: 2
Views: 2554
Reputation: 51
This may because the window textfield in not the key window. Only the key window can accept the user input. So, try make the [textfield.window makeKeyAndVisible];
Upvotes: 0
Reputation: 17378
Ensure that you are setting up your window correctly at launch
And that you are calling
[window setRootViewController:someViewController];
Which is now an error in iOS6 if you dont and...
[window makeKeyAndVisible];
Which isn't an error (to omit) but throws things into wierd land and seems to result in UITextView
and UITextField
not working well.
as in...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.viewController = [[[MyViewController alloc] initWithNibName:nil bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
[window setRootViewController:navigationController];
[window makeKeyAndVisible];
}
Upvotes: 6
Reputation: 547
I am not sure, but it might be a simple problem of text color. Try to set the text color;
[userInput setTextColor:[UIColor blackColor]];
I hope it helps.
Upvotes: 0