3

I'm implementing custom ios keyboard. I have an issue with updates of keyboard views when rotating screen. The problem is that animation of update is not smooth (view sizes and positions change few times). I think this happens because updateViewConstraints() method called twice after rotation. In my override method of updateViewConstraints() I remove and add keyboard height constraint.

let portraitHeight:CGFloat = UIDevice.currentDevice().userInterfaceIdiom == .Pad ? 315 : 264 let landscapeHeight:CGFloat = UIDevice.currentDevice().userInterfaceIdiom == .Pad ? 420 : 200 var heightConstraint: NSLayoutConstraint! override func updateViewConstraints() { super.updateViewConstraints() if (self.view.frame.size.width == 0 || self.view.frame.size.height == 0) { return } let isLandscape = !(self.view!.frame.size.width == self.screenWidth * ((self.screenWidth < self.screenHeight) ? 1 : 0) + self.screenHeight * ((self.screenWidth > self.screenHeight) ? 1 : 0)) self.inputView!.removeConstraint(self.heightConstraint) if (isLandscape) { self.heightConstraint.constant = self.landscapeHeight; self.inputView!.addConstraint(self.heightConstraint) } else { self.heightConstraint.constant = self.portraitHeight; self.inputView!.addConstraint(self.heightConstraint) } } 

Is this okay that updateViewConstraints() called twice when rotating screen? And how to achieve smooth animation on screen rotation?

Thanks for any advance!

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.