娱乐大咖项目- 关注模块
---恢复内容开始---
3 - 关注模块的代码编写
3.1 - 关注模块界面搭建
在这里有一个小细节,就是中间label标签页中文字都是居中,且是分段,如果是从SB,或Xib中要的话,就Option + enter 键就可以换行
3.2 - 关注中的推荐关注模块
需要用到的三方库有:
AFNetworking SVProgressHUD MJExtension MJRefresh
http请求中的get请求,数据格式为JSON格式
采用一个控制器,两个TableView共用数据源的方法
#pragma makr - 实现数据源的方法 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // 左边的类别表格 if (tableView == self.categoryTableView) return self.categories.count; // 右边的用户表格 // 监测footer的状态 [self checkFooterState]; return [ZWSelectedCategory users].count; } - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView == self.categoryTableView){ ZWTuiJianCatrgoryCell *cell = [tableView dequeueReusableCellWithIdentifier:ZWCategotyID]; cell.category = self.categories[indexPath.row]; return cell; }else{ ZWTuiJianUserCell *cell = [tableView dequeueReusableCellWithIdentifier:ZWUserID]; cell.user = [ZWSelectedCategory users][indexPath.row]; return cell; } }
这样一来,就不用再去建两个控制器。
3.3 问题 当两个数据模型,网络请求建立,并且能够显示会出现如下一个问题,由于系统的原意,右边的Tableview会有一部分,看不见
// 设置inset self.automaticallyAdjustsScrollViewInsets = NO; self.categoryTableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0); self.userTableview.contentInset = self.categoryTableView.contentInset;
所以就得设置以上代码,调整两个TableviewInset,这样就不会被上面的导航栏所遮盖。
3.4 问题 解决重复网络请求发送的 通过判断分类模型中数据是否含有用户数据,有就直接刷新表格,没有发送请求,即可完成其相应网络请求
3.5 问题 解决网络慢带来的问题