Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

ios - 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...