Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 当我尝试以交互模式关闭键盘时,我的inputAccessoryView出现错误_Swift_Uitextview_Interactive_Inputaccessoryview_Resignfirstresponder - Fatal编程技术网

Swift 当我尝试以交互模式关闭键盘时,我的inputAccessoryView出现错误

Swift 当我尝试以交互模式关闭键盘时,我的inputAccessoryView出现错误,swift,uitextview,interactive,inputaccessoryview,resignfirstresponder,Swift,Uitextview,Interactive,Inputaccessoryview,Resignfirstresponder,我已经用UITextView实现了inputAccessoryView。我还设置了collectionView.keyboardDismissMode=.interactive 当我使用交互模式打开键盘时,我有两个错误 1) -第一响应者警告:''从层次结构中删除时拒绝了辞职第一响应者 2) -[UIWindow EndDisableingInterfaceAutoRotationAnimated:]在>上调用,但不匹配-BeginDisableingInterfaceAutoRotation。

我已经用UITextView实现了inputAccessoryView。我还设置了collectionView.keyboardDismissMode=.interactive 当我使用交互模式打开键盘时,我有两个错误

1) -第一响应者警告:''从层次结构中删除时拒绝了辞职第一响应者

2) -[UIWindow EndDisableingInterfaceAutoRotationAnimated:]在>上调用,但不匹配-BeginDisableingInterfaceAutoRotation。忽略

Xcode 10和swift 4

CollectionViewController的代码

lazy var containerView: InputAccesoryView = {

    let frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 50)
    let containerView = InputAccesoryView(frame: frame)

    containerView.backgroundColor = UIColor.groupTableViewBackground
    containerView.autoresizingMask = .flexibleHeight
    containerView.delegate = self

    return containerView
}()

override var inputAccessoryView: UIView {
    get {
        return containerView
    }
}

override var canBecomeFirstResponder: Bool {
    return true
}
InputAccessoryView的代码

public let inputTextView: InputTextView = {
    let textView = InputTextView()
    textView.font = UIFont.systemFont(ofSize: 16)
    textView.isScrollEnabled = false
    textView.textAlignment = .left
    textView.layer.cornerRadius = 10
    return textView
}()

private lazy var sendButton: UIButton = {
    let button = UIButton(type: .system)
    button.setImage(UIImage(named: "send2"), for: .normal)
    button.tintColor = .black
    button.addTarget(self, action: #selector(handleUploadComment), for: .touchUpInside)
    return button
}()

override init(frame: CGRect) {
    super.init(frame: frame)

    configureViewComponents()
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

override var intrinsicContentSize: CGSize {
    return CGSize.zero
}

private func configureViewComponents(){


    addSubview(sendButton)
    sendButton.setPosition(top: nil, left: nil, bottom: nil, right: rightAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 8, width: 44, height: 0)
    sendButton.centerYAnchor.constraint(equalTo: layoutMarginsGuide.centerYAnchor).isActive = true

    addSubview(inputTextView)
    inputTextView.setPosition(top: topAnchor, left: leftAnchor, bottom: layoutMarginsGuide.bottomAnchor, right: sendButton.leftAnchor, paddingTop: 8, paddingLeft: 8, paddingBottom: 8, paddingRight: 8, width: 0, height: 0)

    let separatorView = UIView()
    separatorView.backgroundColor = UIColor(red: 230/255, green: 230/255, blue: 230/255, alpha: 1)
    addSubview(separatorView)
    separatorView.setPosition(top: topAnchor, left: leftAnchor, bottom: nil, right: rightAnchor, paddingTop: 0, paddingLeft: 0, paddingBottom: 0, paddingRight: 0, width: 0, height: 0.5)
}

func clearCommentTextView() {
    inputTextView.text = nil
    inputTextView.placeHolder.isHidden = false
}

我也有同样的问题,你有解决这个问题的运气吗?不幸的是没有((这只是iPhone X上的崩溃吗?如果是,那是因为你使用的是
layoutMarginsGuide.bottomAnchor
,你应该使用
safeAreaLayoutGuide
。不,这不仅仅是iPhone X,当然我也使用safeAreaLayoutGuide。我也有同样的问题,你有解决这个问题的运气吗?不幸的是没有((这只是iPhone X上的崩溃吗?如果是,那是因为你使用的是
layoutMarginsGuide.bottomAnchor
,你应该使用
safeAreaLayoutGuide
。不,不仅仅是iPhone X,当然我也使用safeAreaLayoutGuide