iOS聊天界面cell从下至上滚动
来源:互联网 发布:技术支持 盘古网络 编辑:程序博客网 时间:2024/06/12 22:00
import "ChatView.h"
import "ChatCell.h"
@interface ChatView ()
@property (nonatomic, strong) NSMutableArray dataSoure;
@property (nonatomic, strong) UITableView tableView;
@end
@implementation ChatView
(instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {self.backgroundColor = [UIColor clearColor]; self.dataSoure = [NSMutableArray array]; self.tableView = [[UITableView alloc]initWithFrame:self.bounds]; _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.showsVerticalScrollIndicator = NO; _tableView.backgroundColor = [UIColor clearColor]; _tableView.delegate = self; _tableView.dataSource = self;
_tableView.transform = CGAffineTransformMakeScale(1, -1);
[self addSubview:self.tableView];
}
return self;
}(void)reloadData
{
[self.tableView reloadData];
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
}
pragma mark - UITableViewDelegate && UITableViewDataSource
(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.dataSoure.count;
}(UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath)indexPath
{
static NSString identifier = @"LiveChatCell";
ChatCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {cell = [[ChatCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.contentView.transform = CGAffineTransformMakeScale(1, -1);
NSInteger index = self.dataSoure.count-1-indexPath.row;
cell.item = self.dataSoure[index];//cell填充数据
return cell;
}(CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath)indexPath
{
NSInteger index = self.dataSoure.count-1-indexPath.row;
return [ChatCell cellHeightWithItem:self.dataSoure[index] tableView:tableView];
}
pragma mark - UIScrollViewDelegete
//开始拖拽
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(scrollStopTime) object:nil];
}
//结束拖拽
(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
[self performSelector:@selector(scrollStopTime) withObject:nil afterDelay:3.0f];
}(void)scrollStopTime
{
[self.tableView scrollRectToVisible:CGRectMake(0, 0, 1, 1) animated:YES];
}
@end
- iOS聊天界面cell从下至上滚动
- 聊天界面cell的搭建
- 04环信聊天界面 - 完善语音消息在cell上的显示
- swift QQ聊天界面 cell 的计算
- iphone ios 聊天界面
- [IOS]用户聊天界面
- IOS 仿微信聊天界面
- 仿微信聊天界面滚动动画停止效果
- IOS聊天界面键盘处理
- IOS--聊天界面底部菜单栏
- 04环信聊天界面 - 接收方cell的布局
- 04环信聊天界面 - 计算cell的高度
- 04环信聊天界面 - 显示时间的cell
- swift 纯代码自定义cell(qq聊天界面)
- iOS界面不能点击(tableView 的cell 不能使用点击事件,tableView也不能上下滚动)
- iOS cell上的定时器
- 从下至上按层遍历二叉树
- 【iOS开发-65】QQ聊天界面案例:自定义cell、图片拉伸处理、NSNotification通知、键盘与视图移动以及输入框左边缩进处理
- 扣丁学堂笔记第23天Camera、音频录制与Vitamio框架
- Log4J基础详解及示例大全
- 开始写博客,然后坚持下去
- 帝国cms详细权限设置
- epoll在ET和LT模式下读写
- iOS聊天界面cell从下至上滚动
- Android开发:客户端与服务器通过传递和接收json数据进行交互
- tabel 右边箭头样式
- ionic布局模式
- Tomcat详解!
- Linux System Errors code
- 【BZOJ2843&&1180】极地旅行社,LCT练习
- iOS 懒加载相关
- [Asp.net]常见数据导入Excel,Excel数据导入数据库解决方案