当前位置: 首页 > news >正文

自己做网站模板永春县住房和城乡建设网站

自己做网站模板,永春县住房和城乡建设网站,王烨怎么读,专业柳州网站建设哪家便宜看下界面, 这是类似于索引的页面, 只不过木有右侧索引条的布局. 如果想了解通讯录索引的,请移步iOS - 高仿通讯录之商品索引排序搜索. 提供思路如下: 分析界面及接口用 MVC 设计模式来实现(其实核心点都在下面5)创建内外层 Model 并绑定两者 Model两者 Cell 布局的实现 (便于后…看下界面, 这是类似于索引的页面, 只不过木有右侧索引条的布局. 如果想了解通讯录索引的,请移步iOS - 高仿通讯录之商品索引排序搜索. 提供思路如下: 分析界面及接口用 MVC 设计模式来实现(其实核心点都在下面5)创建内外层 Model 并绑定两者 Model两者 Cell 布局的实现 (便于后期界面的快速更改)在外层控制器内进行逻辑操作并请求数据的分区及每个分区行数的处理. 5.1 创建一个保存数据的数组timeList, 这个数组是外层列表数组(分区时间数组) 5.2 拿到数组后, 就可以考虑分区数目及当前分区下 cell 数目 5.3 创建header的界面及数据 5.4 找到相对应的分区去带回内层数组跳转控制器内层数组的传值简单实现.Step1. 分析界面及接口 首先我们先分析这个界面: 很明显这是一个 tableView 的多分区多cell的布局. 这样就好办许多,截取一个分区来做说明. 很明显的能看出来, 这必须只能是 Model 套 Model 了. 分析下接口: ##Step2. 用 MVC 设计模式来实现. 大致思路有了,那我们接着该整理 MVC 了. 简单来说, 就是创建两套 MVC: 外层盘点记录的 MVC 与 内层盘点详情的 MVC(其中内层的还包括外层盘点记录下的每个当前分区下的记录 cell 详情). 看起来是两套 MVC, 由于我们内层的两个数组里字典数据是一样的模型, 我就共用了一套内层 M, 其实是三部分的交错使用. 看个点击分区跳转到盘点详情的 MVC 界面: ##Step3. 创建内外层 Model 并绑定两者 Model 由于只提供思路,就只放核心部分代码. 先创建内层的 子Model(YYPRecordDetailsModel)就和一般正常的 Model 创建一样就好, // 时间 property (nonatomic, copy) NSString *dotime;// 商品名称 property (nonatomic, copy) NSString *commodityName;// 商品金额 property (nonatomic, assign) float commodityAmt;// 实际盘点数量 property (nonatomic, assign) NSInteger inventoryNum;// 库存数量 property (nonatomic, assign) NSInteger stockNum; 复制代码接着创建外层的 一级Model(YYPInventoryRecordModel), 除了几个基本单元素外, 两个内层数组是子 Model 不要忘了要放进去. // 详情全部数据 property (nonatomic, strong) NSArray *inventoryList;// 亏盈数据 property (nonatomic, strong) NSArray *inventoryList2; 复制代码最后在外层 Model 的. m 里实现两者的绑定. (NSDictionary *)objectClassInArray {return {inventoryList : [YYPRecordDetailsModel class], inventoryList2 : [YYPRecordDetailsModel class]}; } 复制代码##Step4. 两者 Cell 布局的实现 页面都是根据产品和 UI 确定, 我们单独写UITableViewCell, 好处就是便于后期界面的快速更改. 可以根据自己的界面来写. 我这里就记录下 Model 赋值. 一定切记,选择相对应的 Model. 我这里展示分区下的 cell 就相对应的是子Modle. // model赋值 - (void)setModel:(YYPRecordDetailsModel *)model {_model model;// 商品名称self.commodityName.text [NSString stringWithFormat:%, model.commodityName];// 单价self.commodityAmt.text [NSString stringWithFormat:¥%.2f, model.commodityAmt];// 盈亏if (model.inventoryNum model.stockNum) {self.result.textColor YYPGrayTitleColor;if (model.inventoryNum model.stockNum) {self.result.text [NSString stringWithFormat:%ld, (model.inventoryNum - model.stockNum)];} else {self.result.text 0;}} else if (model.inventoryNum model.stockNum) { // 亏self.result.textColor YYPRedTitleColor;self.result.text [NSString stringWithFormat:-%ld, (model.stockNum - model.inventoryNum)];} } 复制代码##Step5. 在外层控制器内进行逻辑操作并请求数据的分区及每个分区行数的处理. 其实这里就是重点核心部分了!我要划重点啦~ ####5.1 看盘点记录界面, 就是一个TableView, 那么我们创建一个保存数据的数组timeList, 这个数组是外层列表数组(分区时间数组). property (nonatomic, strong) NSMutableArray *timeList; 复制代码- (NSMutableArray *)timeList {if (!_timeList) {_timeList [NSMutableArray array];}return _timeList; } 复制代码**PS: 切记!!!**千万不要再创建内层数组,容易把自己绕糊涂, 有了外层数组,需要内层数组数据时是可以通过外层数组 timeList 去获取的.譬如行数据:model.inventoryList2[indexPath.row] ####5.2 拿到数组后, 就可以考虑分区数目及当前分区下 cell 数目 #pragma mark - Table view data source- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {self.tableView.mj_footer.hidden self.timeList.count 0;return self.timeList.count; }- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {YYPInventoryRecordModel *model self.timeList[section];return model.inventoryList2.count; }- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {YYPInventoryRecordDetailCell *detailCell [YYPInventoryRecordDetailCell cellWithTableView:tableView];if (self.timeList.count) { // 有时候传值为nilYYPInventoryRecordModel *model self.timeList[indexPath.section];YYPRecordDetailsModel *detailModel model.inventoryList2[indexPath.row];detailCell.model detailModel;}return detailCell; }#pragma mark - UITableViewDelegate- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {return YYPInventoryRecordDetailCellHeight; } 复制代码####5.3 这个时候盘点记录的 cell详情出来了, 接着考虑header的界面及数据. 在viewForHeaderInSection里创建 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section ; 复制代码赋值取当前一级 Model 下字段: [[_timeList objectAtIndex:section] valueForKey:dotime]]; dotime.text [NSString stringWithFormat:%, [[_timeList objectAtIndex:section] valueForKey:dotime]]; 复制代码分区Header内容也是由外层 Model 赋值的, 返回每个分区的内容self.timeList[section] - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {return self.timeList[section]; } 复制代码####5.4 由于我们还有下个跳转页面,同时还是取当前接口数据, 这个时候我们就要找到相对应的分区去跳转即可. 在cell 点击跳转相对来说方便的多,因为这个有系统方法didSelectRowAtIndexPath.只需要找到相对应分区self.timeList[indexPath.section] - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {YYPInventoryRecordModel *model self.timeList[indexPath.section];YYPRecordDetailsController *vc [[YYPRecordDetailsController alloc] init];vc.inventoryList model.inventoryList;[self.navigationController pushViewController:vc animated:YES]; } 复制代码若是header 上也要实现按钮跳转, 可以在viewForHeaderInSection方法里的按钮上加个标记与header的分区section一致, 然后找到相对应分区**self.timeList[sender.tag]**就好. inIcon.tag section; 复制代码实现跳转方法 - (void)btnClick:(UIButton *)sender {// 用 tag 来标记sectionYYPInventoryRecordModel *model self.timeList[sender.tag];YYPRecordDetailsController *vc [[YYPRecordDetailsController alloc] init];vc.inventoryList model.inventoryList;[self.navigationController pushViewController:vc animated:YES]; } 复制代码####5.5 最后就是请求了. 拿到最外层的数组数据就好. [weakSelf.timeList removeAllObjects]; NSArray *currentPageArray [YYPInventoryRecordModel loadInventoryRecordInfoFromJson:json[data]]; [weakSelf.timeList addObjectsFromArray:currentPageArray]; 复制代码至于上拉加载更多数据/下拉刷新新数据 及 网络不佳状态重新加载获取请求这些都是按自己项目需求添加的. 这里就不一一展示了. ##Step6. 跳转控制器内层数组的传值简单实现. 这其实就是一个简单的正常的 MVC. 就是不需要请求接口,就是正向传值带回来一个数组. .h 里露出一个属性便于传值. // 详情全部数据 property (nonatomic, strong) NSArray *inventoryList; 复制代码在. m 里创建一个保存接收数据的可变数据 // 详情全部数据 property (nonatomic, strong) NSMutableArray *goodList; 复制代码需要加载inventoryList数据带回到goodList. #pragma mark - 懒加载- (NSMutableArray *)goodList {if (!_goodList) {_goodList [NSMutableArray array];[_goodList addObjectsFromArray:_inventoryList];}return _goodList; } 复制代码简单的Table view data source方法: #pragma mark - Table view data source- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {return self.goodList.count; }- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {YYPRecordDetailsCell *cell [YYPRecordDetailsCell cellWithTableView:tableView];if (self.goodList.count) { // 有时候传值为nilYYPRecordDetailsModel *model self.goodList[indexPath.row];cell.model model;}return cell; } 复制代码这个时候,完整测试下效果吧: 如果需要看订单详情页那种Model 套 Model 的请移步: Model套Model之iOS模型闲聊
http://www.zqtcl.cn/news/508164/

相关文章:

  • 建一个购物网站多少钱wordpress托管在哪里
  • 怎么建设免费网站北京最大的火车站
  • 做视频网站被判刑豫建设标 网站
  • 济南网站建设济南wordpress计次查询
  • 做英文小工具网站赚钱商城网站是免费开吗
  • 做网站需要注意的问题seo推广代运营
  • 采购网站大全wordpress decorum
  • wordpress建站教程道一网页效果图素材
  • 广州网站开发哪家专业免费咨询怀孕医生
  • 洛阳网站的优化阿里云购买域名后怎么建网站
  • 我是做环保类产品注册哪些浏览量大的网站推销自己的产品比较好呢网站功能模块设计
  • 叫人做网站多少钱百度免费网站怎样建设
  • 本地南通网站建设新手编程入门先学什么
  • asp网站开发的背景与环境久久建筑网会员
  • 河北省住房建设厅官方网站个人计算机做服务器建网站
  • 上海自助建站费用页游网站
  • 浙江省住建厅网站沈阳网站建设专家
  • 基础建设文本网站施工企业在施工过程中发现设计文件和图纸有差错的应当
  • 做互联网交易网站的条件17网站一起做网店揭阳
  • 做公司网站合同asp.net sql server网站建设 pdf
  • 建筑兼职网站天津网站优化公司哪家好
  • 怎么做网站设计商城型网站开发网站建设
  • 建设网站目录帮别人做网站要投资吗
  • 网站meta 优化建议桥梁建设设计网站
  • 网站建设 甘肃wordpress rss去掉
  • 网站安全检测大连网龙建站优化推广
  • 人才网官方网站公众号排名优化软件
  • 淘宝返利网站建设软件开发哪里学好
  • 烟台网站制作公司如何注册国外网站
  • discuz企业网站网站可以做音频线吗