I tried to add two different toolbars to Inputaccessoryview. But InputAccessoryView's subview toolbar buttons not working.
I tried to create 2 seperate uitoolbar and add one of them as inputaccessoryview. Then I added second toolbar as subview. It looks very well but buttons not working, it's just looking in there.
There is my code
let entryToolbar = UIToolbar(frame:CGRect(x: 0, y: -50, width: UIScreen.main.bounds.width, height: 50))
entryToolbar.barStyle = Theme.barStyle!
entryToolbar.tintColor = Theme.userColor
let sendToolbar = UIToolbar(frame:CGRect(x: 0, y: -0, width: UIScreen.main.bounds.width, height: 50))
sendToolbar.barStyle = Theme.barStyle!
sendToolbar.tintColor = Theme.userColor
sendToolbar.items = [
UIBarButtonItem(title: "gönder", style: .plain, target: self, action: #selector(gonder)),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil),
UIBarButtonItem(title: "vazgeç", style: .plain, target: self, action: #selector(vazgec))]
entryToolbar.items = [
UIBarButtonItem(title: "(bkz:)", style: .plain, target: self, action: #selector(bkz)),
UIBarButtonItem(title: "hede", style: .plain, target: self, action: #selector(hede)),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil),
UIBarButtonItem(title: "*", style: .plain, target: self, action: #selector(gizlihede)),
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil),
UIBarButtonItem(title: "-spoiler-", style: .plain, target: self, action: #selector(spoiler)),
UIBarButtonItem(title: "http://", style: .plain, target: self, action: #selector(link))]
sendToolbar.sizeToFit()
sendToolbar.addSubview(entryToolbar)
entryGir.inputAccessoryView = sendToolbar
How can I add multi toolbar as inputaccessoryview and how could it work this buttons?
There is a view of my viewcontroller. https://i.sstatic.net/PXmGl.png
You cannot add any subviews to UIToolbar
. What you have to do to make your toolbar as in provided image is: create custom class that extends UIView
, configure that custom UIView
UI by code or load it from NIB
and write all the control logic of buttons and other UI elements in that custom class implementation. Then just use that custom UIView
as your inputAccessoryView
.
inputAccessoryView
implementation here.