ios - Any way to know the custom keyboard frame in viewDidLoad or viewWillAppear? -
i'm developing custom keyboard extension , noticed when call self.inputview.frame.size.width
in either viewdidload
or viewwillappear
, returns 0 or incorrect number. in viewdidappear
correct. problem because need update size of elements in keyboard based on available width , height. right handling detecting frame size in viewwilllayoutsubviews
, called several times before correct. works, user can see elements changing size in keyboard - frame not correct until after has been presented user. problem because need update scroll position once elements correct size, i'm forced delay until viewdidappear
. isn't great user experience things jumping around after it's been presented.
is there way know height , width of keyboard earlier in life cycle can set size of elements before become visible user?
i using xib create keyboard interface utilizes auto layout. how add keyboard:
let keyboardnib = uinib(nibname: "keyboardview", bundle: nil) let keyboardinterface = keyboardnib.instantiatewithowner(self, options: nil)[0] as! uiview keyboardinterface.settranslatesautoresizingmaskintoconstraints(false) self.inputview.addsubview(keyboardinterface) let verticalconstraints: [nslayoutconstraint] = nslayoutconstraint.constraintswithvisualformat("v:|-0-[keyboardinterface]-0-|", options: nslayoutformatoptions(0), metrics: nil, views: ["keyboardinterface": keyboardinterface, "view": view]) as! [nslayoutconstraint] let horizontalconstraints: [nslayoutconstraint] = nslayoutconstraint.constraintswithvisualformat("h:|-0-[keyboardinterface]-0-|", options: nslayoutformatoptions(0), metrics: nil, views: ["keyboardinterface": keyboardinterface]) as! [nslayoutconstraint] self.inputview.addconstraints(verticalconstraints) self.inputview.addconstraints(horizontalconstraints)
Comments
Post a Comment