旋转后获得iPad屏幕键盘的大小

旋转后获得iPad屏幕键盘的大小,第1张

概述对于我正在为iPad设计的应用程序,我有一个滚动视图,其中包含一些文本字段/文本视图.为了保持一切可见,我调整滚动视图的contentSize属性,在底部添加一个缓冲区,该缓冲区对应于键盘与滚动视图重叠的程度.这是代码(这里有一些特定于应用程序的东西,但希望不是那么多,你无法理解它): - (void)viewWillAppear:(BOOL)animated{ [super viewW 对于我正在为iPad设计的应用程序,我有一个滚动视图,其中包含一些文本字段/文本视图.为了保持一切可见,我调整滚动视图的contentSize属性,在底部添加一个缓冲区,该缓冲区对应于键盘与滚动视图重叠的程度.这是代码(这里有一些特定于应用程序的东西,但希望不是那么多,你无法理解它):

- (voID)vIEwWillAppear:(BOol)animated{    [super vIEwWillAppear:animated];    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];    [nc addobserver:self selector:@selector(keyboarDWillShow:) name:UIKeyboarDWillShowNotification object:nil];    [nc addobserver:self selector:@selector(keyboarDWillHIDe:) name:UIKeyboarDWillHIDeNotification object:nil];}- (voID)vIEwWilldisappear:(BOol)animated{    [super vIEwWilldisappear:animated];    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];    [nc removeObserver:self name:nil object:nil];}- (voID)keyboarDWillShow:(NSNotification *)aNotification{    NSValue *animationCurve = [[aNotification userInfo] valueForKey:UIKeyboardAnimationCurveUserInfoKey];    UIVIEwAnimationCurve curve;    [animationCurve getValue:&curve];    NSValue *animationDuration = [[aNotification userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey];    NSTimeInterval duration;    [animationDuration getValue:&duration];    NSValue *endingFrame = [[aNotification userInfo] valueForKey:UIKeyboardFrameEndUserInfoKey];    CGRect frame;    [endingFrame getValue:&frame];    [UIVIEw beginAnimations:@"keyboarDWillShow" context:bodyVIEw];    [UIVIEw setAnimationCurve:curve];    [UIVIEw setAnimationDuration:duration];     // Re-draw code here.    [UIVIEw commitAnimations];}- (voID)keyboarDWillHIDe:(NSNotification *)aNotification{    NSValue *animationCurve = [[aNotification userInfo] valueForKey:UIKeyboardAnimationCurveUserInfoKey];    UIVIEwAnimationCurve curve;    [animationCurve getValue:&curve];    NSValue *animationDuration = [[aNotification userInfo] valueForKey:UIKeyboardAnimationDurationUserInfoKey];    NSTimeInterval duration;    [animationDuration getValue:&duration];    [UIVIEw beginAnimations:@"keyboarDWillHIDe" context:bodyVIEw];    [UIVIEw setAnimationCurve:curve];    [UIVIEw setAnimationDuration:duration];    // Re-draw code here    [UIVIEw commitAnimations];      }

我的问题是:在旋转过程中我如何处理键盘尺寸?旋转iPad时,我没有收到任何键盘通知,但键盘的大小发生了显着变化.理想情况下,我只需将键盘在横向模式下重叠的数量调整为contentSize属性的高度,但是如果不在两个方向上对键盘的高度进行硬编码,我就看不到这样做的好方法.不想做.

解决方法 我偶然发现了这个调试的答案.事实证明,当iPad从纵向旋转到横向时,肖像键盘会在横向键盘出现之前隐藏(并发送其通知)(并发送其通知).所以,只要你说明这一点,你就可以了. 总结

以上是内存溢出为你收集整理的旋转后获得iPad屏幕键盘的大小全部内容,希望文章能够帮你解决旋转后获得iPad屏幕键盘的大小所遇到的程序开发问题。

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

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

原文地址: https://outofmemory.cn/web/1084314.html

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

发表评论

登录后才能评论

评论列表(0条)

保存