大佬教程收集整理的这篇文章主要介绍了iOS_21团购_发送请求获取【点评】数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
请求结果简单显示:
用到的点评封装的类:
使用tableView简单展示:
// // DealListController.m // 帅哥_团购 // // Created by beyond on 14-8-14. // Copyright (C) 2014年 com.beyond. All rights reserved. // 点击dock上面的【团购】按钮对应的控制器,上面是导航栏,导航栏右边是searchBar,导航栏左边是一个大按钮(TopMenu)(内部由三个小按钮组成<TopMenuItem>) #import "DealListController.h" // 导航栏左边是一个大按钮(顶部菜单) #import "TopMenu.h" #import "DPAPI.h" #import "MetaDataTool.h" // 数据模型,对应服务器返回的一个团购字典 #import "Deal.h" // 数据模型,里面有一个数组,存放所有商区(DiStrict)对象 #import "City.h" @interface DealListController ()<DPrequestDelegate> { // 用于保存服务器返回的所有deals字典,并转成一个个deal对象 NSMutableArray *_deals; } @end @implementation DealListController - (void)viewDidLoad { [super viewDidLoad]; // 1,设置上方的导航栏,右边是搜索bar,左边是一个大的VIEW(内有三个按钮) [self addNaviBarBtn]; _deals = [NSMutableArray array]; } // 1,左边是一个大的VIEW(内有三个按钮) - (void)addNaviBarBtn { // 1.监听城市改变的通知 kAddAllNotes(dataChangE) // 2.右边的搜索框 UISearchBar *s = [[UISearchBar alloc] init]; s.frame = CGRectMake(0,210,35); s.placeholder = @"请输入商品名、地址等"; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:s]; // 3.左边的菜单栏,导航栏左边是一个大按钮(顶部菜单) TopMenu *topMenu = [[TopMenu alloc] init]; // 4.用于点击顶部按钮时,容纳创建出来的底部弹出菜单(包括一个contentView和cover,contentView又包括scrollView和subtitleImgView),本成员是由创建此TopMenu的外部赋值传入,这里是控制器的view,就是导航栏下面的所有区域 topMenu.controllerView = self.view; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:topMenu]; } // temp -- test - (void)dataChange { DPAPI *dpapi = [[DPAPI alloc]init]; [dpapi requestWithURL:@"v1/deal/find_deals" params:@{@"city": [MetaDataTool sharedMetaDataTool].currentCity.namE} delegate:self]; } // temp -- test - (void)request:(DPrequest *)request didFinishLoadingWithResult:(id)result { [_deals removeAllObjects]; NSArray *arr = result[@"deals"]; for (NSDictionary *Dict in arr) { Deal *deal = [[Deal alloc]init]; [deal SETVALuesWithDict:Dict]; [_deals addObject:deal]; } // 接下来就可以给tableView提供数据源了 [self.tableView reloadData]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return _deals.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowATindexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"Beyond"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (cell == nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reusEIDentifier:cellID]; } // 设置cell中独一无二的内容 Deal *deal = [_deals objectATindex:indexPath.row]; cell.textLabel.text = deal.title; cell.detailTextLabel.text = deal.desc; cell.accessoryType = UITableViewCellAccessoryDisclosureInDicator; // 返回cell return cell; } @end
以上是大佬教程为你收集整理的iOS_21团购_发送请求获取【点评】数据全部内容,希望文章能够帮你解决iOS_21团购_发送请求获取【点评】数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。