Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard and cursor show, but I can't type inside UITextFields and UITextViews

On an iPad with iOS 6 GM. I have 6 UITextFields, 3 UITextViews, and a UIButton that triggers a popover/actionsheet.

When I select one of the UITextFields or UITextViews, the keyboard pops up and the cursor appears, but I can't enter text. If I press the UIButton to show the popover and then tap outside it to dismiss it and go back to the UITextFields or UITextViews, they work.

I have UITextxxxx.delegate = self; set for all of them. "Enabled" and "User Interaction Enabled" checked off in the xibs, UITextFieldDelegate and UITextViewDelegate in my .h file as well as:

- (BOOL)disablesAutomaticKeyboardDismissal {
    return NO;
}


- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    
    return YES;
    
}

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField {
    
    return YES;
    
}

- (IBAction)textFieldReturn:(id)sender {
    
    [sender resignFirstResponder];
}



- (BOOL)textViewShouldBeginEditing:(UITextView *)textView {
    
    if (textView == notestextView){
        [notestextView becomeFirstResponder];
    }
    if (textView == notestextViewTwo){
        [notestextViewTwo becomeFirstResponder];
    }
    if (textView == notestextViewThree){
        [notestextViewThree becomeFirstResponder];
    }
    
    return YES;
    
}

- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
    
    return YES;
    
}

I even tried to [xxxxxxx becomeFirstResponder]; in viewDidLoad. That pops the keyboard and places the cursor in the field at runtime, but I still can't type in it until I tap the UIButton to show the popover.

Anyone know why I can't type in the fields and why envoking the popover "fixes it"?

UPDATE 9/18: I pushed a new view in my app that just has a view with a textfield and a textview. Delegates are all set up. Same behavior. Keyboard and cursor appear, but no typing. That rules out the popovercontroller messing with things.

I'm strongly starting to think this is an iOS 6 bug. This is pretty much the same view I had in the iPhone version of my app on iOS 4 and 5 and I never had a problem. The only difference between the iPhone and iPad version is the way the imagepicker is presented. You have to use a popover for the iPad. That’s why I was thinking that the popover delegate had something to do with it.

Is there any kind of fundamental difference between implementing UITextFields and UITextViews in iOS 6 that I don't know about? Seems unlikely.

If it helps my app flows like this:

Main View with 10 buttons

  • each button pushes a tableview via a navigation controller
  • tableviews push a detail view - textfields and textviews exhibit behavior described above
  • tableview also has an add button that pushes a modal view to add new items - textfields and textviews exhibit behavior described above
like image 251
RyeMAC3 Avatar asked Sep 16 '12 14:09

RyeMAC3


4 Answers

This was originally an iPhone app built on iOS 5. To make it an iPad app, I just duplicated the project and upgraded all the .xibs to iPad versions. I don't know if it's a bug or not, or if it's something to do with the upgrade to iOS 6, but doing it like that messes something up with the MainWindow.xib.

In the MainWindow xib, I typed in "MainViewController" for the title (It was previously blank.)

enter image description here

And checked off "Visible at Launch". Even though it is already visible at launch, not having that checked off screws something up.

enter image description here

Now all my text views and text fields work.

like image 162
RyeMAC3 Avatar answered Nov 01 '22 20:11

RyeMAC3


I ran into this same issue, make sure that the app delegate has a [self.window makeKeyAndVisible]. That solved it for me.

like image 42
Matthew Smith Avatar answered Nov 01 '22 21:11

Matthew Smith


For me your solution doesn't work so I found another.

I'm using Revmob Ads so fullscreen view and banner view are loading when app is launched. Revmob uses some staff for displaying same banner in all viewcontrollers I think here is issue. When I disabled revmob I can add text to my textfield.

like image 2
Danil Avatar answered Nov 01 '22 20:11

Danil


This is apparently bug in iOS 6. Just put [searchBar becomeFirstResponder]; into searchBarTextDidBeginEditing method:

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
    if (!self.window.isKeyWindow) {
        [self.window makeKeyAndVisible];
    }
}

This solution works for me.

like image 2
Borut Tomazin Avatar answered Nov 01 '22 21:11

Borut Tomazin