2016-07-27 22 views
0

現在の入力アクセサリビューの上に複数のボタンを含むUIを追加しようとしています。私の現在の入力アクセサリビューは、成長しているtextField(iOS標準のテキストメッセージアプリ)です。inputAccessoryView内のuiviewの上に垂直にuiviewを追加するにはどうすればよいですか?

class ViewController: UIViewController { 

let textInputBar = ALTextInputBar() 

// The magic sauce 
// This is how we attach the input bar to the keyboard 
override var inputAccessoryView: UIView? { 
    get { 
     return textInputBar 
    } 
} 

// Another ingredient in the magic sauce 
override func canBecomeFirstResponder() -> Bool { 
    return true 
} 
} 

Example of what I'm trying to do, the app (Facebook Messenger) has a growing textfield or textinput, and in this case, an bar of buttons bellow.

My current view, as mentioned earlier.

+0

あなたはショットをスクリーニングすることができます。詳細については。 –

+0

TextFieldとButtonビューの両方を含むビューをアクセサリビューとして追加することはできません。 V:| [BUTTONVIEW] [TEXTFIELD] | - 。またはキーボードの表示/非表示の通知を使用して、手動でビューに追加します。例えば。通知からキーボードの高さを得ることができます。 inputAccessoryViewの高さを計算し、この高さの値を使用してボタンのビューを配置します。 kbを閉じたときに削除します – RJE

+0

@Ramkumarchintala私がやろうとしていることと現在のアプリケーションの写真を追加しました。 – leecan999

答えて

0

try this code

class ViewController: UIViewController { 
@IBOutlet weak var myTextField: UITextField! 
var textInputBar:UIView = ALTextInputBar()// if it is a uiview type 

    override func viewDidLoad() { 
    super.viewDidLoad() 
    myTextField.inputAccessoryView = textInputBar 
} 


} 
+0

ありがとうございますが、残念ながら、動作しませんでした。それは私にエラーを与えた:プロパティに割り当てることはできません:inputAccessoryViewは取得専用のプロパティです。 – leecan999

関連する問題