ios – 调整inputAccessoryView中的文本字段大小

我一直试图让UITextView整周调整大小.我不知道应该怎么做,所以我决定包括几乎所有相关的代码.

我有这个对话视图:

这个对话视图是一个内部有UITableView的UIViewController(使用约束).我有一个自定义UIView子类ConversationToolbar设置为inputAccessoryView(包含它的UIViewController可以成为第一个响应者,因此视图始终可见),其中包含2个子视图.一个用于UITextView和左右按钮,一个用于表情符号.表情符号仅在点按左键时显示

当选择一个时,它会显示在浮动标签中:

当使用多行时,我现在无法调整此UITextView的大小.我曾尝试自己计算所有帧,但那时似乎与我的约束以某种奇怪的方式发生冲突.几乎总是UITextView太小或仅在我按另一个键来更新视图后调整大小.或者UITextView在键盘上变大,或者在键盘解除时滑出视图.

我已从我的代码删除了所有调整大小的功能,我想知道我需要做什么才能调整大小.

在我的ConversationViewController中:

var toolbar: ConversationToolbar!

override var inputAccessoryView: UIView! {
    get {
        if toolbar == nil {
            toolbar = NSBundle.mainBundle().loadNibNamed("ConversationToolbar",owner: nil,options: nil).last! as ConversationToolbar
            toolbar.frame.size = CGSize(width: UIScreen.mainScreen().bounds.size.width,height: 80)
            toolbar.delegate = self
            toolbar.setDraft(conversation.draft)
        }
        return toolbar
    }
}

使用ConversationToolbar.xib是:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsversion="6254" systemVersion="14D87p" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
    <dependencies>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
    </dependencies>
    <objects>
        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
        <view contentMode="scaletoFill" id="iN0-l3-epB" customClass="ConversationToolbar" customModule="Heaven_Help" customModuleProvider="target">
            <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
            <subviews>
                <view contentMode="scaletoFill" translatesAutoresizingMaskIntoConstraints="NO" id="s5O-PN-dtz">
                    <rect key="frame" x="0.0" y="554" width="600" height="46"/>
                    <subviews>
                        <button opaque="NO" contentMode="scaletoFill" horizontalCompressionResistancePriority="749" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pbw-hg-sNn">
                            <rect key="frame" x="0.0" y="0.0" width="36" height="46"/>
                            <inset key="contentEdgeInsets" minX="8" minY="0.0" maxX="8" maxY="0.0"/>
                            <state key="normal" title="

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...