博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第11月第31天 keyboardwillshow CGAffineTransformMakeTranslation
阅读量:4952 次
发布时间:2019-06-11

本文共 2087 字,大约阅读时间需要 6 分钟。

1.

- (void)dealloc{    [[NSNotificationCenter defaultCenter] removeObserver:self];}- (void)registerNotification {    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showKeyboard:) name:UIKeyboardWillShowNotification object:nil];    [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(hideKeyboard:) name:UIKeyboardWillHideNotification object:nil];}#pragma mark - keyboard- (void)showKeyboard:(NSNotification *)noti {    NSDictionary *info=[noti userInfo];        NSTimeInterval duration = [info[UIKeyboardAnimationDurationUserInfoKey] doubleValue];    UIViewAnimationOptions options = [info[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue] << 16;        CGRect keyboardRect = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue];    CGFloat keyboardHeight = MIN(CGRectGetWidth(keyboardRect), CGRectGetHeight(keyboardRect));        [UIView animateWithDuration:duration delay:0 options:options animations:^{        CGFloat compareH = self.tableView.contentSize.height -(self.view.height - 45 - 64 - keyboardHeight);        if (compareH >  0) {            if (compareH < keyboardHeight) {                self.tableView.transform = CGAffineTransformMakeTranslation(0, -compareH);            } else {                self.tableView.transform = CGAffineTransformMakeTranslation(0, -keyboardHeight);            }        }                self.bottomView.transform = CGAffineTransformMakeTranslation(0, -keyboardHeight);            } completion:nil];}- (void)hideKeyboard:(NSNotification *)noti {        NSDictionary *info=[noti userInfo];        NSTimeInterval duration = [info[UIKeyboardAnimationDurationUserInfoKey] doubleValue];    UIViewAnimationOptions options = [info[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue] << 16;        [UIView animateWithDuration:duration delay:0 options:options animations:^{                self.tableView.transform = CGAffineTransformIdentity;        self.bottomView.transform = CGAffineTransformIdentity;            } completion:nil];    }

 

转载于:https://www.cnblogs.com/javastart/p/7457470.html

你可能感兴趣的文章
Repeater+DataPagerSource分页
查看>>
模块化导出
查看>>
pagebean pagetag java 后台代码实现分页 demo 前台标签分页 后台java分页
查看>>
Sphinx 2.0.8 发布,全文搜索引擎 Installing Sphinx on Windows
查看>>
pod
查看>>
ResultSet 可滚动性和可更新性
查看>>
VS2013 C++代码运行问题
查看>>
iOS 加载图片选择imageNamed 方法还是 imageWithContentsOfFile?
查看>>
LUOGU P2986 [USACO10MAR]伟大的奶牛聚集Great Cow Gat…
查看>>
toad for oracle中文显示乱码
查看>>
scala的REPL shell的调用
查看>>
SQL中Group By的使用
查看>>
Mybatis映射原理,动态SQL,log4j
查看>>
哪个微信编辑器比较好用?
查看>>
错误org/aopalliance/intercept/MethodInterceptor解决方法
查看>>
Pylint在项目中的使用
查看>>
使用nginx做反向代理和负载均衡效果图
查看>>
access remote libvirtd
查看>>
gdb调试中出现No symbol table is loaded. Use the "file" command.问题
查看>>
(4) Orchard 开发之 Page 的信息存在哪?
查看>>