iOS8: What's going on with moving views during keyboard transitions?

后端 未结 3 1516
野的像风
野的像风 2020-12-03 01:58

After switching to iOS8, I\'m getting weird behavior when I move views during a keyboard transition. Can anyone explain what\'s going on?

Here\'s a minimal example t

3条回答
  •  情话喂你
    2020-12-03 02:41

    It's AutoLayout. Something changed in iOS8 and you can't just change frame or center points anymore if you have AutoLayout enabled. You have to create an outlet(s) of your constraint (vertical space) and update it accordingly instead of changing frame position. Constraints are like any other ui control and can have an outlet. Constraint change can be animated.

    Example:

    [UIView animateWithDuration:[notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue] delay:0 options:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue] animations:^{        
        self.bottomSpaceConstraint.constant = adjustmentedValue;
        [self.view layoutIfNeeded];        
    } completion:^(BOOL finished) {
    }];
    

提交回复
热议问题