Swift: InputaccessoryView не активируется (iPhone X)
У меня есть пользовательский вид для inputaccessoryview, который прекрасно работает на всех устройствах, кроме iPhone X. Он даже отображается правильно, так как я использую safeAreaLayoutGuide.
Однако я не могу щелкать по кнопкам и текстовому полю (когда клавиатура скрыта, поэтому, когда представление ввода находится внизу) только в последнем горизонтальном ряду пикселей внизу и когда клавиатура действительно отображается.
Кто-нибудь знает, где моя ошибка?
Просмотр настроек в пользовательском представлении (клавиатура):
private func setup_view(){
if #available(iOS 11.0, *){
self.insetsLayoutMarginsFromSafeArea = true
addSubview(backgroundView)
backgroundView.leftAnchor.constraint(equalTo: safeAreaLayoutGuide.leftAnchor).isActive = true
backgroundView.rightAnchor.constraint(equalTo: safeAreaLayoutGuide.rightAnchor).isActive = true
backgroundBottomAnchor = backgroundView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor, constant: 0)
backgroundBottomAnchor.isActive = true
backgroundHeightAnchor = backgroundView.heightAnchor.constraint(equalTo: heightAnchor)
backgroundHeightAnchor.isActive = true
}else{
addSubview(backgroundView)
backgroundView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
backgroundView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
backgroundBottomAnchor = backgroundView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0)
backgroundBottomAnchor.isActive = true
backgroundHeightAnchor = backgroundView.heightAnchor.constraint(equalTo: heightAnchor)
backgroundHeightAnchor.isActive = true
}
addSubview(moreButton)
moreButton.leftAnchor.constraint(equalTo: backgroundView.leftAnchor, constant: 15).isActive = true
moreButton.widthAnchor.constraint(equalToConstant: 18).isActive = true
moreButton.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor, constant: -12.5).isActive = true
moreButton.heightAnchor.constraint(equalToConstant: 25).isActive = true
addSubview(voiceButton)
voiceButton.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor, constant: -8).isActive = true
voiceButton.heightAnchor.constraint(equalToConstant: 34).isActive = true
voiceButton.widthAnchor.constraint(equalTo: voiceButton.heightAnchor).isActive = true
voiceButtonConstraint = voiceButton.rightAnchor.constraint(equalTo: rightAnchor, constant: -10)
voiceButtonConstraint.isActive = true
addSubview(sendButton)
sendButton.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor, constant: -8).isActive = true
sendButton.heightAnchor.constraint(equalToConstant: 34).isActive = true
sendButton.widthAnchor.constraint(equalTo: sendButton.heightAnchor).isActive = true
sendButtonConstraint = sendButton.rightAnchor.constraint(equalTo: rightAnchor, constant: -7)
sendButtonConstraint.isActive = true
addSubview(textField)
textField.leftAnchor.constraint(equalTo: moreButton.rightAnchor, constant: 15).isActive = true
textField.centerYAnchor.constraint(equalTo: backgroundView.centerYAnchor).isActive = true
textFieldHeightAnchor = textField.heightAnchor.constraint(equalTo: heightAnchor, constant: -10)
textFieldHeightAnchor.isActive = true
textField.delegate = self
textFieldRightAnchor = textField.rightAnchor.constraint(equalTo: rightAnchor, constant: -108)
textFieldRightAnchor.isActive = true
addSubview(cameraButton)
cameraButton.bottomAnchor.constraint(equalTo: backgroundView.bottomAnchor, constant: -8).isActive = true
cameraButton.heightAnchor.constraint(equalToConstant: 34).isActive = true
cameraButton.widthAnchor.constraint(equalTo: cameraButton.heightAnchor).isActive = true
cameraButtonConstraint = cameraButton.rightAnchor.constraint(equalTo: voiceButton.leftAnchor, constant: -10)
cameraButtonConstraint.isActive = true
addSubview(playButton)
playButton.centerYAnchor.constraint(equalTo: backgroundView.centerYAnchor).isActive = true
playButton.heightAnchor.constraint(equalToConstant: 25).isActive = true
playButton.widthAnchor.constraint(equalTo: playButton.heightAnchor).isActive = true
playButton.rightAnchor.constraint(equalTo: voiceButton.leftAnchor, constant: -10).isActive = true
playButton.isHidden = true
addSubview(animationView)
animationView.centerXAnchor.constraint(equalTo: backgroundView.leftAnchor, constant: 25).isActive = true
animationView.centerYAnchor.constraint(equalTo: backgroundView.centerYAnchor).isActive = true
animationView.heightAnchor.constraint(equalToConstant: 34).isActive = true
animationView.widthAnchor.constraint(equalTo: animationView.heightAnchor).isActive = true
animationView.isHidden = true
addSubview(circleView)
circleView.centerXAnchor.constraint(equalTo: backgroundView.leftAnchor, constant: 25).isActive = true
circleView.centerYAnchor.constraint(equalTo: backgroundView.centerYAnchor).isActive = true
circleView.heightAnchor.constraint(equalToConstant: 34).isActive = true
circleView.widthAnchor.constraint(equalTo: circleView.heightAnchor).isActive = true
circleView.isHidden = true
addSubview(deleteButton)
deleteButton.centerXAnchor.constraint(equalTo: backgroundView.leftAnchor, constant: 20).isActive = true
deleteButton.centerYAnchor.constraint(equalTo: backgroundView.centerYAnchor).isActive = true
deleteButton.heightAnchor.constraint(equalToConstant: 40).isActive = true
deleteButton.widthAnchor.constraint(equalTo: animationView.heightAnchor).isActive = true
deleteButton.isHidden = true
addSubview(recordingLabel)
recordingLabel.leftAnchor.constraint(equalTo: deleteButton.rightAnchor, constant: 15).isActive = true
recordingLabel.centerYAnchor.constraint(equalTo: backgroundView.centerYAnchor).isActive = true
recordingLabel.heightAnchor.constraint(equalTo: backgroundView.heightAnchor, constant: -10).isActive = true
recordingLabel.rightAnchor.constraint(equalTo: playButton.leftAnchor, constant: -15).isActive = true
recordingLabel.isHidden = true
sendButton.isHidden = true
}