【问题标题】:UITextField inside UITableviewcell. editable but keyboard is not showingUITableviewcell 内的 UITextField。可编辑但键盘未显示
【发布时间】:2020-12-31 15:06:03
【问题描述】:

这里不是 iOS 专家。使用 xcode 11 和最新的 iOS 和目标 C。我希望用户能够添加一些文本。文本字段是可编辑的,但我没有看到键盘。如果我单击下一个单元格,我会在控制台中收到约束警告。关于这个主题有很多问题。但没有任何帮助。 textFieldShouldBeginEditing() 确实被调用并且我返回 YES。

2020-09-13 12:47:18.294987-0700 EWF[31667:891775] -[ewfSubMenuViewController textFieldShouldBeginEditing:] tag 12377 2
2020-09-13 12:47:23.760577-0700 EWF[31667:891775] last selected 0
2020-09-13 12:47:23.760831-0700 EWF[31667:891775] -[ewfSubMenuViewController tableView:didSelectRowAtIndexPath:]: index 1 mainmenu 0
2020-09-13 12:47:25.898776-0700 EWF[31667:891775] -[ewfSubMenuViewController textFieldShouldBeginEditing:] tag 12378 1
2020-09-13 12:47:25.914790-0700 EWF[31667:891775] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x60000399aa80 'assistantHeight' TUISystemInputAssistantView:0x7fcf4d64d6f0.height == 38   (active)>",
    "<NSLayoutConstraint:0x6000039e94f0 'assistantView.bottom' TUISystemInputAssistantView:0x7fcf4d64d6f0.bottom == _UIKBCompatInputView:0x7fcf4d744070.top   (active)>",
    "<NSLayoutConstraint:0x6000039e9400 'assistantView.top' V:|-(0)-[TUISystemInputAssistantView:0x7fcf4d64d6f0]   (active, names: '|':UIInputSetHostView:0x7fcf4fb23800 )>",
    "<NSLayoutConstraint:0x6000039f9b80 'inputView.top' V:|-(0)-[_UIKBCompatInputView:0x7fcf4d744070]   (active, names: '|':UIInputSetHostView:0x7fcf4fb23800 )>"
)

尝试了所有这些:

 cell.tfItemNote.delegate = self;
    //cell.tfItemNote.clearButtonMode = UITextFieldViewModeNever;
    //[cell.contentView addSubview:cell.tfItemNote];
    //cell.accessoryType = UITableViewCellAccessoryNone;
    //[cell.tfItemNote becomeFirstResponder];
    
    tableView.userInteractionEnabled = YES;
    cell.tfItemNote.userInteractionEnabled = YES;
    
    //tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    //tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive;
    //cell.tfItemNote.returnKeyType = UIReturnKeyDone;

我希望在用户点击返回时关闭键盘。

感谢任何帮助。 谢谢。

【问题讨论】:

    标签: ios objective-c xcode uitableview uitextfield


    【解决方案1】:

    在模拟器中运行时可以使用快捷键Command+K切换键盘。

    这是模拟器的行为,用真机不会有这个问题。

    【讨论】:

    • 成功了!谢谢。花了很多时间修改代码。每当用户在同一视图中的另一个单元格的文本字段中滚动或点击时,我如何关闭键盘?
    • 嗨@user3282227,你应该使用这个库:github.com/hackiftekhar/IQKeyboardManager
    猜你喜欢
    • 1970-01-01
    • 2013-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-30
    • 1970-01-01
    • 2015-07-15
    • 1970-01-01
    相关资源
    最近更新 更多