
有智能解决方案吗?
解决方法 为了解决你的问题,有很多解决方案.从使用UIScrolVIEw到更改框架或约束.如果您想使用UIScrolVIEw,您应该将UIVIEw注册表格插入到UIScrolVIEw并设置内容大小.
代码狙击手如何处理键盘和scrollvIEw.
首先,您应该知道何时显示键盘并隐藏.使用通知:
- (voID)registerForKeyboardNotifications{ [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboarDWasShown:) name:UIKeyboardDIDShowNotification object:nil]; [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboarDWillBeHIDden:) name:UIKeyboarDWillHIDeNotification object:nil];} 之后使用方法(keyboarDWasShown和keyboarDWillBeHIDden)的通知来改变contentInsets.
更改contentInsets的示例:
- (voID)keyboarDWasShown:(NSNotification*)aNotification{ NSDictionary* info = [aNotification userInfo]; CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0,0.0,kbSize.height,0.0); scrollVIEw.contentInset = contentInsets; scrollVIEw.scrollindicatorInsets = contentInsets;}- (voID)keyboarDWillBeHIDden:(NSNotification*)aNotification{ UIEdgeInsets contentInsets = UIEdgeInsetsZero; scrollVIEw.contentInset = contentInsets; scrollVIEw.scrollindicatorInsets = contentInsets;} 最后解决方案取决于您的选择,您可以像UIScrolVIEw参数一样更改框架或约束.
总结以上是内存溢出为你收集整理的启用键盘时可以使iOS页面可滚动全部内容,希望文章能够帮你解决启用键盘时可以使iOS页面可滚动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)