类似朋友圈,评论View
来源:互联网 发布:以太坊 挖矿 windows 编辑:程序博客网 时间:2024/04/28 23:56
CommentInputView
最近有一个类似微信朋友圈页面的需求,琢磨了许久,才使用了现在的方式来实现,可能还有别的实现方式,回头整理下,传上来,抛砖引玉。今天上一个评论的View.
1、实现思路
本来想着写一个View,然后替换textview的inputView的,但是今天没有这么实现,
而是写了一个view,然后利用通知中心监控键盘的活动状态,在要弹出键盘的时候,把该view的origin.y移动到键盘上边,键盘要消失的时候,一样的道理,来把view的origin.y移出屏幕外
2、使用
首先,在init
或者viewDidLoad
中创建监听
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(visiableAnimate:) name:UIKeyboardWillShowNotification object:nil];[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(visiableAnimate:) name:UIKeyboardDidShowNotification object:nil];[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fadeAnimate:) name:UIKeyboardWillHideNotification object:nil];self.replyView = [[ReplyInputView alloc]initWithFrame:CGRectMake(0, kScreenSize.height - 40, kScreenSize.width, 40)];//view的最大高度self.replyView.maxHeight = 60;//评论的人的名字self.replyView.replyUserName = @"John";//评论按钮可否点击self.replyView.sendBtn.enabled = NO;//使用代理把用户评论的信息传回来self.replyView.commentDelegate = self;[self.view addSubview:self.replyView];- (void)visiableAnimate:(NSNotification *)notify {NSString *rectStr = [NSString stringWithFormat:@"%@",notify.userInfo[@"UIKeyboardBoundsUserInfoKey"]];CGFloat keyboardHeight = [[[rectStr componentsSeparatedByString:@","] lastObject] floatValue];self.replyView.sendBtn.enabled = YES;[UIView animateWithDuration:.25 animations:^{CGRect origin = self.replyView.frame;origin.origin.y = kScreenSize.height - keyboardHeight - self.replyView.frame.size.height;self.replyView.frame = origin;}];}- (void)fadeAnimate:(NSNotification *)notify {self.replyView.sendBtn.enabled = NO;[UIView animateWithDuration:.25 animations:^{CGRect origin = self.replyView.frame;origin.origin.y = kScreenSize.height - self.replyView.frame.size.height;self.replyView.frame = origin;}];}#pragma mark - ReplyInputViewDelegate- (void)didUserCompleteCommentWithString:(NSString *)commentStr {NSLog(@"\n填写评论完成\n评论为:%@",commentStr);self.replyView.inputView.text = [NSString stringWithFormat:@"回复:%@",self.replyView.replyUserName];self.replyView.userTypedStr = self.replyView.inputView.text;}
详情
github
1 0
- 类似朋友圈,评论View
- android Recyclerview实现类似朋友圈点击添加图片的view
- 类似微信5.x朋友圈的弹出框评论功能
- android类似微信朋友圈评论效果,listview定位,item总在输入法上面的位置
- Android:一个TextView分段改变样式、添加监听事件的实现方式(类似朋友圈评论)
- 高仿微信朋友圈评论popwindow
- CommentListTextView 实现朋友圈评论列表
- 类似网易评论UI
- 类似点赞、评论
- Android朋友圈评论功能知识点记录
- Android 朋友圈 输入框评论效果
- android---朋友圈评论功能自定义对话框
- android仿微信朋友圈点击评论效果
- Android 朋友圈 输入框评论效果
- Android 朋友圈之评论回复列表
- 实现类似微信朋友圈或者QQ空间,评论回复,九宫格布局。处理键盘弹出后定位到当前点击的被评论人处。另:滑动时候FPS在57-60之间,纵享丝滑
- 类似微信文本输入框实现,底部评论输入View,随着文字的增加,textView自增长高度
- iOS - 类似朋友圈的社交界面实现
- 函数调用时的参数传递和栈帧结构问题
- Struts遍历标签s:iterator总结
- 全排列生成算法
- MySQL在没有可视化界面下查看数据库内容
- 第九篇:亚盘的平衡手法
- 类似朋友圈,评论View
- 抓包工具Fiddler的使用教程(三):如何模拟弱网环境
- Android 自定义橡皮擦效果
- 设置APACHE支持SSL
- 合理使用JTAG和IMPACT帮助你调试FPGA不能启动的问题
- gitHub 的使用
- 将CString类型转换为double类型的方法
- Oracle数据库中文拼音排序问题
- centos6.x 中查看mysql的相关配置(安装位置,数据存放位置等等)