iOS 8横向纵向模式下的自定义键盘

iOS 8横向纵向模式下的自定义键盘,第1张

概述我想在iOS 8中制作自定义键盘.我希望在手机旋转到横向模式时更改它的大小. -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ NSUserDefaults *def = [NSUserDefa 我想在iOS 8中制作自定义键盘.我希望在手机旋转到横向模式时更改它的大小.

-(voID)willRotatetoInterfaceOrIEntation:(UIInterfaceOrIEntation)toInterfaceOrIEntation duration:(NSTimeInterval)duration{    NSUserDefaults *def = [NSUserDefaults standardUserDefaults];    if ((toInterfaceOrIEntation==UIInterfaceOrIEntationPortrait) || (toInterfaceOrIEntation==UIInterfaceOrIEntationPortrait))    {        [def setobject:@"No" forKey:@"LandScape"];        [def synchronize];        islandscapemode = NO;        NSLayoutConstraint *_heightConstraint =        [NSLayoutConstraint constraintWithItem: self.vIEw                                     attribute: NSLayoutAttributeHeight                                     relatedBy: NSLayoutRelationEqual                                        toItem: nil                                     attribute: NSLayoutAttributeNotAnAttribute                                    multiplIEr: 0.0                                      constant: 266];        [self.vIEw addConstraint:_heightConstraint];           }    else    {        [def setobject:@"Yes" forKey:@"LandScape"];        [def synchronize];        NSLayoutConstraint *_heightConstraint =        [NSLayoutConstraint constraintWithItem: self.vIEw                                     attribute: NSLayoutAttributeHeight                                     relatedBy: NSLayoutRelationEqual                                        toItem: nil                                     attribute: NSLayoutAttributeNotAnAttribute                                    multiplIEr: 0.0                                      constant: 266];        [self.vIEw addConstraint:_heightConstraint];        self.vIEw.backgroundcolor=[UIcolor greencolor];        islandscapemode = YES;    }    //  [self determineKeyboardNib:toInterfaceOrIEntation];}

但它不起作用.我该怎么办?

解决方法
willRotatetoInterfaceOrIEntation:duration:

在iOS 8中已弃用.请尝试使用

vIEwWillTransitionToSize:withTransitionCoordinator:

iOS Developer Library: viewWillTransitionToSize

此函数为您提供对容器视图的新大小和转换协调器的引用.然后,您可以将键盘大小调整为新的屏幕尺寸.

还有一个附加到过渡协调器的功能,允许您在屏幕旋转时为视图设置动画和/或在屏幕旋转后完成功能块.

iOS Developer Library: UIViewControllerTransitionCoordinator

animatealongsIDeTransition:completion:

animatealongsIDeTransitionInVIEw:animation:completion:

至于您的原始问题,您是否在设置约束后尝试在视图上调用layoutIfNeeded?

总结

以上是内存溢出为你收集整理的iOS 8横向纵向模式下的自定义键盘全部内容,希望文章能够帮你解决iOS 8横向纵向模式下的自定义键盘所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1024589.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存