自定义键盘iOS-方向更改-未平滑应用自动布局约束

自定义键盘iOS-方向更改-未平滑应用自动布局约束,ios,iphone,keyboard,custom-keyboard,Ios,Iphone,Keyboard,Custom Keyboard,我已经创建了一个自定义键盘,它还支持横向和纵向方向。我的问题是,当我更改方向时,键盘视图会更改其高度和宽度,这与本机键盘不同。下面添加了视频。我希望键盘可以像本机键盘一样调整大小 我正在更新ViewWillTransitionSize中添加的键盘高度 - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coo

我已经创建了一个自定义键盘,它还支持横向和纵向方向。我的问题是,当我更改方向时,键盘视图会更改其高度和宽度,这与本机键盘不同。下面添加了视频。我希望键盘可以像本机键盘一样调整大小

我正在更新ViewWillTransitionSize中添加的键盘高度

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];

[self updateKeyboardHeight];
}

-(void)updateKeyboardHeight{
if (self.view.frame.size.width == 0 || self.view.frame.size.height == 0)
    return;
[self.inputView removeConstraint:self.heightConstraint];

CGSize screenSize = [[UIScreen mainScreen] bounds].size;
CGFloat realScreenHeight = MAX(screenSize.height, screenSize.width);
if([[UIScreen mainScreen] bounds].size.width == realScreenHeight)
{
    //Landscape
    self.isLandscape = YES;
    self.heightConstraint.constant = self.landscapeHeight;
    _currentOrientation = LKeyboardButtonLandscape;
    [self.view addConstraint:self.heightConstraint];

}
else
{
    //Portrait
    self.isLandscape = NO;
    self.heightConstraint.constant = self.portraitHeight;
     _currentOrientation = LKeyboardButtonPortrait;
    [self.view addConstraint:self.heightConstraint];

}
}
-(void)视图将转换大小:(CGSize)带有转换协调器的大小:(id)协调器
{
[super ViewWillTransitionSize:size with TransitionCoordinator:coordinator];
[自更新键盘高度];
}
-(无效)updateKeyboardHeight{
if(self.view.frame.size.width==0 | | self.view.frame.size.height==0)
返回;
[self.inputView removeConstraint:self.heightConstraint];
CGSize screenSize=[[UIScreen mainScreen]界限].size;
CGFloat realScreenHeight=最大值(screenSize.height,screenSize.width);
如果([[UIScreen mainScreen]bounds].size.width==realScreenHeight)
{
//景观
self.isLandscape=是;
self.heightConstraint.constant=self.landscapeHeight;
_currentOrientation=LKeyboardButtonLandscape;
[self.view addConstraint:self.heightConstraint];
}
其他的
{
//肖像画
self.isLandscape=否;
self.heightConstraint.constant=self.height;
_currentOrientation=LKeyboardButtonPortrait;
[self.view addConstraint:self.heightConstraint];
}
}

没有可用的视频。@Priyal…抱歉刚才补充说你也应该在设备上试用,而不仅仅是模拟器。@Rikh..谢谢你的回复…在设备上我也得到了同样的结果。