键盘和光标显示,但我无法在UITextFields和UITextViews中键入 [英] Keyboard and cursor show, but I can't type inside UITextFields and UITextViews

查看:127
本文介绍了键盘和光标显示,但我无法在UITextFields和UITextViews中键入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有iOS 6 GM的iPad上。我有6个UITextFields,3个UITextViews和一个UIButton触发一个popover / actionsheet。



当我选择一个UITextFields或UITextViews时,键盘弹出光标出现,但我无法输入文字。如果我按UIButton显示popover,然后点击外面的它关闭它,并返回到UITextFields或UITextViews,他们工作。



我有UITextxxxx.delegate =自;为他们设置。在.ib文件中的xibs,UITextFieldDelegate和UITextViewDelegate中检查Enabled和User Interaction Enabled,以及:

   - (BOOL)disableAutomaticKeyboardDismissal {
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];
}

返回YES;

}

- (BOOL)textViewShouldEndEditing:(UITextView *)textView {

return YES;

}

我甚至尝试[xxxxxxx成为FirstResponder];在viewDidLoad。弹出键盘并将光标放在运行时的字段中,但是我仍然无法输入,直到我点击UIButton来显示popover。



任何人都知道为什么我不能输入字段,为什么煽动popover修复它?



更新9/18:我推出了一个新的视图在我的应用程序,只有具有textfield和textview的视图。代表全部成立。相同的行为键盘和光标出现,但不打字。这就排除了popover控制器搞乱了事情。



我很开始认为这是一个iOS 6的错误。这与iOS 4和5中我的应用程序的iPhone版本一样,我从来没有遇到任何问题。 iPhone和iPad版本之间的唯一区别是显示图像显示的方式。你必须使用一个popover的iPad。这就是为什么我认为popover代表与它有关系。



在iOS 6中实现UITextFields和UITextView之间有什么根本的区别,知道吗似乎不太可能。



如果它有助于我的应用程序流程如下:


主使用10个按钮查看




  • 每个按钮通过导航控制器推送表视图

  • tableviews推一个细节视图 - textfields和textviews展示了上述行为

  • tableview还有一个添加按钮,可以推动模态视图添加新项目 - textfields和textviews展示上述的行为



解决方案

这是原来是在iOS 5上构建的iPhone应用程序。应用程序,我只是复制了项目,并将所有的 .xibs 升级到iPad版本。我不知道这是否是一个错误,或者是升级到iOS 6有什么关系,但是这样做就像在$ code> MainWindow.xib 。



在MainWindow xib中,我在MainViewController中输入了标题(以前是空白的) )





并检查启动时可见。即使它在启动时已经可以看到,没有检查是否有螺丝钉。





现在我所有的文本视图和文本字段都可以正常工作。


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

解决方案

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.)

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

Now all my text views and text fields work.

这篇关于键盘和光标显示,但我无法在UITextFields和UITextViews中键入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆