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

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

问题描述

在装有 iOS 6 GM 的 iPad 上.我有 6 个 UITextFields、3 个 UITextViews 和一个触发弹出框/操作表的 UIButton.

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

当我选择 UITextFields 或 UITextViews 之一时,键盘弹出并出现光标,但我无法输入文本.如果我按下 UIButton 以显示弹出框,然后在其外部点击以将其关闭并返回 UITextFields 或 UITextViews,它们就可以工作.

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.

我有 UITextxxxx.delegate = self;为所有人设置.启用"和启用用户交互"在我的 .h 文件中的 xibs、UITextFieldDelegate 和 UITextViewDelegate 以及:

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;
    
}

我什至尝试过 [xxxxxxx becomeFirstResponder];在 viewDidLoad 中.这会在运行时弹出键盘并将光标放在字段中,但我仍然无法输入它,直到我点击 UIButton 以显示弹出框.

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"?

更新 9/18:我在我的应用程序中推送了一个新视图,该视图只有一个带有文本字段和文本视图的视图.代表已全部成立.相同的行为.键盘和光标出现,但没有打字.这排除了 popovercontroller 搞砸的事情.

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.

我开始强烈认为这是 iOS 6 的错误.这与我在 iOS 4 和 5 上我的应用程序的 iPhone 版本中的视图几乎相同,而且我从来没有遇到过问题.iPhone 和 iPad 版本之间的唯一区别是图像选择器的呈现方式.您必须为 iPad 使用弹出框.这就是为什么我认为弹出框代表与它有关.

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.

在 iOS 6 中实现 UITextFields 和 UITextViews 之间有什么我不知道的根本区别吗?似乎不太可能.

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:

带有 10 个按钮的主视图

Main View with 10 buttons

  • 每个按钮通过导航控制器推送一个表格视图
  • tableviews 推送详细视图 - textfields 和 textviews 表现出上述行为
  • tableview 也有一个添加按钮,用于推动模态视图以添加新项目 - 文本字段和文本视图表现出上述行为

推荐答案

这原本是一个基于 iOS 5 构建的 iPhone 应用.为了让它成为 iPad 应用,我只是复制了项目并升级了所有 .xibs 到 iPad 版本.我不知道这是否是一个错误,或者它是否与升级到 iOS 6 有关,但是这样做会弄乱 MainWindow.xib.

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.

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

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

并勾选了Visible at Launch".即使它在发布时就已经可见,但如果不检查它就会搞砸.

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天全站免登陆