ios - becomeFirstResponder not showing from viewDidLoad -
here have simple example. im calling firstresponder
in viewdidload
. accessory view shows after tapping screen. why isn't showing start?
class testviewcontroller: mainpageviewcontroller { private let accessoryview = uiview() //textinputview() // messageinputaccessoryview() override var inputaccessoryview: uiview { return accessoryview } override var canbecomefirstresponder: bool { return true } override func viewdidload() { super.viewdidload() accessoryview.backgroundcolor = .red accessoryview.frame = cgrect(x: 0, y: 0, width: 300, height: 50) self.becomefirstresponder() // additional setup after loading view. let tap = uitapgesturerecognizer(target: self, action: #selector(tappo)) self.view.isuserinteractionenabled = true self.view.addgesturerecognizer(tap) tappo() } func tappo() { self.becomefirstresponder() } }
viewwillappear
better place put becomesfirstresponder
. try that.
Comments
Post a Comment