objective c - iOS 8 Custom Keyboard: issues when changing default keyboard height -


having implemented similar method described in ios 8 custom keyboard: changing height, have 2 main issues can't seem figure out.

1) when rotation occurs, there terribly noticeable jump. keyboard rotates @ current height, , after rotation has completed abruptly jump new height.

2) contents of keyboard don't seem drawn until rotation complete. causing whole list of problems when trying use various available callbacks. example, i'm trying set contentsize height of scrollview, @ bottom of keyboard (similar old emoji keyboard), same height scrollview. however,

scrollview.contentsize = scrollview.frame.size.height 

does not work because scrollview (nor enclosing view - tried also) hasn't reached final bounds yet. i've verified checking bounds after keyboard loaded - scrollview return correct value height.

the same thing occurs when try set size contents of collectionview (which comprises main body of keyboard):

func collectionview(collectionview: uicollectionview, layout collectionviewlayout: uicollectionviewlayout, sizeforitematindexpath indexpath: nsindexpath) -> cgsize {     let heightportrait: cgfloat = 0.8     let heightlandscape: cgfloat = 0.8     var collectionviewheight = collectionview.bounds.size.height     var portrait = collectionviewheight * heightportrait     var landscape = collectionviewheight * heightlandscape     var newdimensions: cgfloat      newdimensions = uiscreen.mainscreen().bounds.size.width < uiscreen.mainscreen().bounds.size.height ? portrait : landscape      return cgsize(width: newdimensions, height: newdimensions) } 

i've implemented viewwilltransitiontosize each object update on rotation, when it's called, bounds once again not yet set:

override func viewwilltransitiontosize(size: cgsize, withtransitioncoordinator coordinator: uiviewcontrollertransitioncoordinator) {     self.setkeyboardheight() // change keyboard height default setting.     self.buildscrollview() // populate scrollview , set contentsize cell attributes.      println("before: \(self.view4.frame.size.height)") // same 'after' (see few lines below), swapping out view4 (the scrollview's superview) scrollview doesn't change anything.      coordinator.animatealongsidetransition(nil, completion: { context in         self.collectionview?.collectionviewlayout.invalidatelayout()          println("after: \(self.view4.frame.size.height)")      })     super.viewwilltransitiontosize(size, withtransitioncoordinator: coordinator) } 

i've been cracking head on way long, if can me figure out eternally grateful. thank , time may take answer/work on this!!


Comments