iOS 11 inputAccessoryView损坏 [英] iOS 11 inputAccessoryView broken

查看:213
本文介绍了iOS 11 inputAccessoryView损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在视图控制器上为UIToolBar/Accessory View进行了以下设置

I have the following set up for my UIToolBar / Accessory View on a view controller

@IBOutlet var inputFieldView: UIToolbar!
override var canBecomeFirstResponder: Bool{
    return true
}

override var inputAccessoryView: UIView?{
    return self.inputFieldView
}

然后在我的viewDidLoad里面:

then inside my viewDidLoad I have:

    let seperator = UIView(frame: CGRect(x:0 , y: 0, width: ScreenSize.width(), height: 1))
    seperator.backgroundColor = UIColor.lightBackground
    self.inputFieldView.addSubview(seperator)
    self.inputFieldView.isTranslucent = false
    self.inputFieldView.setShadowImage(UIImage(), forToolbarPosition: .any)
    self.inputFieldView.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default)
    self.inputFieldView.removeFromSuperview()

这对于ios 10和9版本效果很好.它是带有发送"按钮的文本视图.它位于屏幕的底部,当被按下时,它成为第一响应者,可以抬起键盘并正确定位自己.

This worked great for ios versions 10 and 9. It is a text view with a "Send" button. It sits at the bottom of the screen and when pressed, becomes first responder allowing the keyboard to come up and it positions itself correctly.

在ios 11中,当它位于底部时,我什至无法单击它,因此我根本无法键入.

With ios 11 i cannot even click on it when it is at the bottom, so I cannot type at all.

推荐答案

已解决.看来UIToolbar在iOS 11中无法正常工作.

Solved it. It looks like UIToolbar's just are not working correctly in iOS 11.

将其更改为UIView并删除

Changed it to an UIView and removed

self.inputFieldView.isTranslucent = false
self.inputFieldView.setShadowImage(UIImage(), forToolbarPosition: .any)
self.inputFieldView.setBackgroundImage(UIImage(), forToolbarPosition: .any, barMetrics: .default)

使其正常工作(也可以通过xib中的UIToolbar将其更改为UIView.)

got it working (and changed it to a UIView from UIToolbar in the xib as well.)

这篇关于iOS 11 inputAccessoryView损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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