Change height of inputAccessoryView issue

后端 未结 6 1882
感情败类
感情败类 2020-12-24 03:19

When I change the height of inputAccessoryView in iOS 8, the inputAccessoryView not go to the right origin, but covers the keyboard.

6条回答
  •  臣服心动
    2020-12-24 04:07

    One way you can update the constraint mentioned in Yijun's answer when changing the height of the inputAccessoryView is by overwriting setFrame: on your inputAccessoryView. This doesn't rely on the height constraint being the first in the array.

    - (void)setFrame:(CGRect)frame {
        [super setFrame:frame];
    
        for (NSLayoutConstraint *constraint in self.constraints) {
            if (constraint.firstAttribute == NSLayoutAttributeHeight) {
                constraint.constant = frame.size.height;
                break;
            }
        }
    }
    

提交回复
热议问题