GUWENViewController.m 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. //
  2. // GUWENViewController.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/8/19.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "GUWENViewController.h"
  9. #import "SQFiltrateView.h"
  10. #import "GuWenCell.h"
  11. #import "GuWenDetailViewController.h"
  12. #import "CityListViewController.h"
  13. #import "GUWenlistModel.h"
  14. @interface GUWENViewController ()<UITableViewDelegate,UITableViewDataSource,CityListViewDelegate,UITextFieldDelegate>{
  15. SQFiltrateItem *item1;
  16. SQFiltrateView *filtrateView;
  17. UITableView *newtableView;
  18. NSMutableArray *dataArray;
  19. int pageIndex;
  20. int pageSize;
  21. int pageNumber;
  22. UIView *showView;
  23. NSString *timeOrhaoping;
  24. NSString *guwentype;
  25. NSString *Sheng;
  26. NSString *Shi;
  27. NSString *Qu;
  28. UIView *textBGview;
  29. UIView *dhView;
  30. UIButton *backButton;
  31. }
  32. @end
  33. @implementation GUWENViewController
  34. - (void)viewWillAppear:(BOOL)animated
  35. {
  36. [super viewWillAppear:animated];
  37. [self.navgationBar setHidden:YES];
  38. if (self.navigationController.viewControllers.count <= 1) {
  39. NSLog(@"111");
  40. if (NavHeader == 88) {
  41. textBGview.sd_layout
  42. .leftSpaceToView(dhView, 15)
  43. .heightIs(30)
  44. .topSpaceToView(dhView, 45)
  45. .rightSpaceToView(dhView, 60);
  46. }else{
  47. textBGview.sd_layout
  48. .leftSpaceToView(dhView, 15)
  49. .heightIs(30)
  50. .topSpaceToView(dhView, 25)
  51. .rightSpaceToView(dhView, 60);
  52. }
  53. backButton.hidden = YES;
  54. }else{
  55. NSLog(@"222");
  56. if (NavHeader == 88) {
  57. textBGview.sd_layout
  58. .leftSpaceToView(dhView, 55)
  59. .heightIs(30)
  60. .topSpaceToView(dhView, 45)
  61. .rightSpaceToView(dhView, 60);
  62. }else{
  63. textBGview.sd_layout
  64. .leftSpaceToView(dhView, 55)
  65. .heightIs(30)
  66. .topSpaceToView(dhView, 25)
  67. .rightSpaceToView(dhView, 60);
  68. }
  69. backButton.hidden = NO;
  70. }
  71. }
  72. - (void)viewDidDisappear:(BOOL)animated
  73. {
  74. [super viewDidDisappear:animated];
  75. [self.navgationBar setHidden:NO];
  76. }
  77. - (void)viewDidLoad {
  78. [super viewDidLoad];
  79. [self setNavTitle:@"顾问"];
  80. [self loadsUI];
  81. [self loaddata];
  82. [self classificationview];
  83. [self loadsView];
  84. [self addRefreshing];
  85. [self networkRequest:nil Shijian:timeOrhaoping Sousuo:self.seachStr GuWentype:guwentype];
  86. // Do any additional setup after loading the view.
  87. }
  88. - (void)loaddata{
  89. dataArray = NewMutableArrayInit;
  90. pageIndex = 1;
  91. pageSize = 10;
  92. pageNumber = 1;
  93. timeOrhaoping = @"0";
  94. guwentype = @"";
  95. Sheng = @"";
  96. Shi = @"";
  97. Qu = @"";
  98. }
  99. - (void)networkRequest:(id)object Shijian:(NSString *)sortType Sousuo:(NSString *)name GuWentype:(NSString *)consultantType
  100. {
  101. int pageNumberIndex=1;
  102. if (!object) {
  103. [MBProgressHUD showLoadToView:self.view title:@"请稍后..."];
  104. }else if ([object isKindOfClass:[MJRefreshNormalHeader class]]) {
  105. pageNumberIndex = 1;
  106. }else if ([object isKindOfClass:[MJRefreshBackNormalFooter class]]) {
  107. pageNumberIndex = pageNumber+1;
  108. }
  109. NSMutableDictionary *parameters = NewMutableDictionaryInit;
  110. [parameters safeSetObject:@(pageSize) forKey:@"pageSize"];
  111. [parameters safeSetObject:@(pageNumberIndex) forKey:@"pageNo"];
  112. [parameters safeSetObject:timeOrhaoping forKey:@"sortType"];//排序 0时间 1好评率
  113. [parameters safeSetObject:name forKey:@"name"];//搜索输入名称
  114. [parameters safeSetObject:consultantType forKey:@"consultantType"]; // 顾问类型 0 专利代理人 1 专利顾问 2 版权顾问 3 商标顾问
  115. [parameters safeSetObject:Sheng forKey:@"province"];//省
  116. [parameters safeSetObject:Shi forKey:@"city"];//市
  117. [parameters safeSetObject:Qu forKey:@"area"];//区
  118. [NetworkRequestManager requestGetWithInterfacePrefix:JT_NewconsultantList parameters:parameters onSuccess:^(id requestData) {
  119. [self dismiss:object];
  120. if ([requestData[@"error"] count] !=0) {
  121. for (NSDictionary *dic in requestData[@"error"]) {
  122. [MBProgressHUD showError:dic[@"message"] toView:self.view];
  123. }
  124. }else{
  125. pageNumber = pageNumberIndex;
  126. if ([object isKindOfClass:[MJRefreshNormalHeader class]] || pageNumber==1) {
  127. [dataArray removeAllObjects];
  128. }else if ([object isKindOfClass:[MJRefreshBackNormalFooter class]]) {
  129. NSMutableArray *arr = requestData[@"data"][@"list"];
  130. if ([arr count]<=0) {
  131. [[[UIApplication sharedApplication].delegate window] makeToast:NewConnectServerNoMoreDataTitle duration:1.0 position:CSToastPositionBottom];
  132. return;
  133. }
  134. }
  135. for (NSDictionary *dic in requestData[@"data"][@"list"]) {
  136. GUWenlistModel *model = [[GUWenlistModel alloc] initWithDictionary:dic error:nil];
  137. [dataArray addObject:model];
  138. }
  139. //查询不到类型底图
  140. if (dataArray.count<=0) {
  141. [self addErrorLoadingFrame:CGRectMake(0, NavHeader+44, newtableView.width, newtableView.height) title:@"暂无数据" buttonTitle:nil imageString:NewNoDataErrorImage];
  142. }else {
  143. [self hideReloadingview];
  144. [newtableView reloadData];
  145. }
  146. }
  147. } onFailure:^{
  148. [self dismiss:object];
  149. }];
  150. }
  151. #pragma mark -------分类-------------
  152. - (void)classificationview{
  153. UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, NavHeader, SCREEN_WIDTH, 1)];
  154. line.backgroundColor = NewLineGrayColor;
  155. [self.view addSubview:line];
  156. item1 = [[SQFiltrateItem alloc]init];
  157. item1.listType = OptionListType_Cell;
  158. item1.numberType = OptionNumberType_Single;
  159. // NSMutableArray *arr = NewMutableArrayInit;
  160. // for (NSDictionary *dic in industrytypeArray) {
  161. // [arr addObject:dic[@"name"]];
  162. // }
  163. item1.optionData = @[@"时间",@"好评率"];
  164. item1.title = @"时间";
  165. SQFiltrateItem *item2 = [[SQFiltrateItem alloc]init];
  166. item2.listType = OptionListType_Cell;
  167. item2.numberType = OptionNumberType_Single;
  168. /*
  169. 0--专利, 1--软著, 2--项目, 3--版权, 4--工业设计, 5--配方, 6--非标
  170. */
  171. item2.optionData = @[@"不限",@"专利代理人",@"专利顾问",@"版权顾问",@"商标顾问"];
  172. item2.title = @"知识产权顾问";
  173. filtrateView = [[SQFiltrateView alloc]initWithFrame:CGRectMake(0, NavHeader+1, SCREEN_WIDTH, 44)
  174. filtrateItems:@[item1,item2]];
  175. [filtrateView touchBlock:^(SQFiltrateView * _Nonnull view, SQFiltrateItem * _Nonnull item) {
  176. NSLog(@"%@:%@",item.title,item.choseSet);
  177. if ([item.title isEqualToString:@"时间"]) {
  178. for (NSSet *luo in item.choseSet) {
  179. NSString *str = [NSString stringWithFormat:@"%@",luo];
  180. if ([str isEqual:@"0"]) {
  181. NSLog(@"时间");
  182. timeOrhaoping = @"0";
  183. }else{
  184. NSLog(@"好评率");
  185. timeOrhaoping = @"1";
  186. }
  187. }
  188. }else if ([item.title isEqualToString:@"知识产权顾问"]){
  189. for (NSSet *luo in item.choseSet) {
  190. NSString *str = [NSString stringWithFormat:@"%@",luo];
  191. if ([str isEqual:@"0"]) {
  192. NSLog(@"不限");
  193. guwentype = @"";
  194. }else if([str isEqual:@"1"]){
  195. NSLog(@"专利代理人");
  196. guwentype = @"0";
  197. }else if([str isEqual:@"2"]){
  198. NSLog(@"专利顾问");
  199. guwentype = @"1";
  200. }else if([str isEqual:@"3"]){
  201. NSLog(@"版权顾问");
  202. guwentype = @"2";
  203. }else if([str isEqual:@"4"]){
  204. NSLog(@"商标顾问");
  205. guwentype = @"3";
  206. }
  207. }
  208. }
  209. [self networkRequest:nil Shijian:timeOrhaoping Sousuo:@"" GuWentype:guwentype];
  210. }];
  211. [self.view addSubview:filtrateView];
  212. }
  213. #pragma mark ----自定义导航
  214. - (void)loadsUI{
  215. dhView = [UIView new];
  216. dhView.backgroundColor = NewButtonColor;
  217. [self.view addSubview:dhView];
  218. dhView.sd_layout
  219. .leftEqualToView(self.view)
  220. .rightEqualToView(self.view)
  221. .heightIs(NavHeader)
  222. .topEqualToView(self.view);
  223. UIImageView *imgaeview1111= [UIImageView new];
  224. [imgaeview1111 setImage:NewImageNamed(@"pp")];
  225. imgaeview1111.userInteractionEnabled = YES;
  226. [dhView addSubview:imgaeview1111];
  227. imgaeview1111.sd_layout
  228. .leftEqualToView(dhView)
  229. .heightIs(NavHeader)
  230. .rightEqualToView(dhView)
  231. .topEqualToView(dhView);
  232. textBGview = [UIView new];
  233. textBGview.backgroundColor = NewWhiteColor;
  234. ViewBorderRadius(textBGview, 3, 1, NewClearColor);
  235. [dhView addSubview:textBGview];
  236. backButton= [UIButton buttonWithType:UIButtonTypeCustom];
  237. backButton.frame = CGRectMake(10, 27, 30, 30);
  238. [backButton setBackgroundColor:[UIColor clearColor]];
  239. // [backButton setBackgroundImage:NewImageNamed(@"fh") forState:UIControlStateNormal];
  240. [backButton setImage:NewImageNamed(@"fh") forState:UIControlStateNormal];
  241. [backButton addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside];
  242. [dhView addSubview:backButton];
  243. //tj
  244. UIImageView *imageview = [UIImageView new];
  245. [imageview setImage:NewImageNamed(@"search")];
  246. [textBGview addSubview:imageview];
  247. imageview.sd_layout
  248. .widthIs(11)
  249. .heightIs(10)
  250. .centerYEqualToView(textBGview)
  251. .leftSpaceToView(textBGview, 10);
  252. UITextField *textfield = [NewControlPackage textFieldInitWithFrame:CGRectMake(0, 0, 0, 0) backgroundImage:nil backgroundColor:NewWhiteColor textColor:NewGrayColor placeholder:@"请输入关键字" hidden:NO tag:100 font:NewFont(fitScreenWidth(12)) textAlignment:NSTextAlignmentLeft clearButtonMode:UITextFieldViewModeAlways clearsOnBeginEditing:NO adjustsFontSizeToFitWidth:NO secureTextEntry:NO keyboardType:UIKeyboardTypeDefault returnKeyType:UIReturnKeySearch userInteractionEnabled:YES];
  253. textfield.text = self.seachStr;
  254. textfield.delegate = self;//设置代理
  255. [textfield addTarget:self action:@selector(textFieldEditingChanged:) forControlEvents:UIControlEventEditingChanged];
  256. [textBGview addSubview:textfield];
  257. textfield.sd_layout
  258. .leftSpaceToView(textBGview, 30)
  259. .topEqualToView(textBGview)
  260. .bottomEqualToView(textBGview)
  261. .rightEqualToView(textBGview);
  262. UIButton *button = [UIButton new];
  263. [button setImage:NewImageNamed(@"dq") forState:UIControlStateNormal];
  264. NewTouchUpInside(button, buttonclick:);
  265. [dhView addSubview:button];
  266. button.sd_layout
  267. .centerYEqualToView(textBGview)
  268. .heightIs(19)
  269. .widthIs(19)
  270. .rightSpaceToView(dhView, 15);
  271. }
  272. #pragma mark -----加载界面-------
  273. - (void)loadsView{
  274. [self.view addSubview:newtableView = [NewControlPackage tableViewInitWithFrame:CGRectMake(0, NavHeader+44, SCREEN_WIDTH, SCREEN_HEIGHT-NavHeader-44-TABBAR_HEIGHT) backgroundColor:NewLineGrayColor style:UITableViewStyleGrouped delegate:self dataSource:self showsHorizontalScrollIndicator:NO showsVerticalScrollIndicator:NO hidden:NO tag:100 userInteractionEnabled:YES]];
  275. newtableView.separatorStyle = NO;
  276. }
  277. #pragma mark-------------------------UITableView------------------------------------
  278. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  279. {
  280. return 1;
  281. }
  282. //返回每段行数
  283. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  284. {
  285. return dataArray.count;
  286. }
  287. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  288. {
  289. static NSString *Cell = @"Cell";
  290. GuWenCell * cell = [tableView dequeueReusableCellWithIdentifier:Cell];
  291. if (cell == nil) {
  292. cell = [[GuWenCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:Cell];
  293. }
  294. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//(这种是没有点击后的阴影效果)
  295. cell.accessoryType = UITableViewCellAccessoryNone;
  296. if (dataArray.count>0) {
  297. [cell assignment:dataArray[indexPath.row]];
  298. }
  299. return cell;
  300. }
  301. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  302. {
  303. return 150;
  304. }
  305. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  306. GuWenDetailViewController *vc = [[GuWenDetailViewController alloc] init];
  307. GUWenlistModel *model = dataArray[indexPath.row];
  308. vc.ID = model.uid;
  309. NewPushViewController(vc);
  310. }
  311. // tableView 如果是Gruop类型的话,section之间的间距变宽,执行返回高度的同时还需要执行return UIView的代理
  312. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  313. return CGFLOAT_MIN;
  314. }
  315. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  316. return CGFLOAT_MIN;
  317. }
  318. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  319. return [[UIView alloc] init];
  320. }
  321. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  322. return [[UIView alloc] init];
  323. }
  324. #pragma mark - TextField作字符输入限制
  325. - (void)textFieldEditingChanged:(UITextField *)textField
  326. {
  327. if ([textField.text length]>10) {
  328. UITextRange *markedRange = [textField markedTextRange];
  329. if (markedRange) {
  330. return;
  331. }
  332. NSRange range = [textField.text rangeOfComposedCharacterSequenceAtIndex:10];
  333. textField.text = [textField.text substringToIndex:range.location];
  334. [self.view makeToast:@"搜索最多输入10个字哦~" duration:1.5 position:CSToastPositionCenter];
  335. }
  336. // resultsTitleStr = textField.text;
  337. NSLog(@"%@",textField.text);
  338. }
  339. - (void)buttonclick:(UIButton *)sender {
  340. CityListViewController *cityListView = [[CityListViewController alloc]init];
  341. cityListView.delegate = self;
  342. //热门城市列表
  343. cityListView.arrayHotCity = [NSMutableArray arrayWithObjects:@"全国",@"北京",@"上海",@"天津",@"重庆",@"成都",@"广州",@"深圳",@"深圳",@"西安",@"南京",@"杭州", nil];
  344. //历史选择城市列表
  345. cityListView.arrayHistoricalCity = [NSMutableArray arrayWithObjects:@"福州",@"厦门",@"泉州", nil];
  346. //定位城市列表
  347. cityListView.arrayLocatingCity = [NSMutableArray arrayWithObjects:@"长沙", nil];
  348. // [self presentViewController:cityListView animated:YES completion:nil];
  349. NewPushViewController(cityListView);
  350. }
  351. - (void)didClickedWithCityName:(NSString*)cityName
  352. {
  353. NSString *sheng;
  354. NSString *shi;
  355. NSString *qu;
  356. NSString *path = [[NSBundle mainBundle] pathForResource:@"locationAll" ofType:@"txt"];
  357. NSString *content = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
  358. NSDictionary *dic = [self jsonStringToKeyValues:content];
  359. NSMutableArray *array1= dic[@"list"];
  360. NSLog(@"%@",cityName);
  361. for (int i = 0; i<array1.count; i++) {
  362. NSMutableArray *array2 = array1[i][@"cityList"];
  363. for (int j = 0; j<array2.count; j++) {
  364. NSString *chengshi = array2[j][@"name"];
  365. if ([chengshi isEqualToString:@"市辖区"]) {
  366. if ([cityName isEqualToString:array1[i][@"name"]]) {
  367. sheng = array1[i][@"id"];
  368. }
  369. }else if ([chengshi rangeOfString:cityName].location != NSNotFound) {
  370. //包含
  371. sheng = array1[i][@"id"];
  372. shi = array2[j][@"id"];
  373. }
  374. }
  375. }
  376. Sheng = sheng;
  377. Shi = shi;
  378. [self networkRequest:nil Shijian:timeOrhaoping Sousuo:@"" GuWentype:guwentype];
  379. NSLog(@"省:%@市:%@区:%@",sheng,shi,qu);
  380. }
  381. //json字符串转化成OC键值对
  382. - (id)jsonStringToKeyValues:(NSString *)JSONString {
  383. NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
  384. NSDictionary *responseJSON = nil;
  385. if (JSONData) {
  386. responseJSON = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil];
  387. }
  388. return responseJSON;
  389. }
  390. #pragma mark - 上拉下拉初始化
  391. - (void)addRefreshing
  392. {
  393. __weak typeof(self) weakSelf = self;
  394. __weak UITableView *tableView = newtableView;
  395. tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
  396. if ([NetworkRequestManager connectedToNetwork]) {
  397. // [weakSelf networkRequest:tableView.mj_header];
  398. [self networkRequest:tableView.mj_header Shijian:timeOrhaoping Sousuo:@"" GuWentype:guwentype];
  399. }else{
  400. [tableView.mj_header endRefreshing];
  401. }
  402. }];
  403. tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
  404. if ([NetworkRequestManager connectedToNetwork]) {
  405. // [weakSelf networkRequest:tableView.mj_footer];
  406. [self networkRequest:tableView.mj_footer Shijian:timeOrhaoping Sousuo:@"" GuWentype:guwentype];
  407. }else{
  408. [tableView.mj_footer endRefreshing];
  409. }
  410. }];
  411. }
  412. - (void)dismiss:(id)object
  413. {
  414. if ([object isKindOfClass:[MJRefreshNormalHeader class]]) {
  415. __weak UITableView *newvc = newtableView;
  416. [newvc.mj_header endRefreshing];
  417. }else if ([object isKindOfClass:[MJRefreshBackNormalFooter class]]){
  418. __weak UITableView *newvc = newtableView;
  419. [newvc.mj_footer endRefreshing];
  420. }else {
  421. [MBProgressHUD hideHUDForView:self.view];
  422. }
  423. }
  424. #pragma mark- 外部触发自动刷新
  425. - (void)autoDownRefresh
  426. {
  427. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  428. [self autoRefresh];
  429. });
  430. }
  431. #pragma mark- 网络请求
  432. - (void)autoRefresh
  433. {
  434. __weak UITableView *tableView = newtableView;
  435. [tableView.mj_header beginRefreshing];
  436. }
  437. #pragma mark 初始化展示框
  438. - (void) addErrorLoadingFrame:(CGRect)frame title:(NSString *)text buttonTitle:(NSString *)buttonText imageString:(NSString *)image
  439. {
  440. if(!showView)
  441. {
  442. [self.view addSubview:showView = [[UIView alloc] initWithFrame:frame]];
  443. [showView setHidden:NO];
  444. [showView setBackgroundColor:NewBgGrayColor];
  445. UIImage *NOimg = [UIImage imageNamed:image];
  446. UIImageView *tempIcon = [[UIImageView alloc]initWithImage:NOimg];
  447. [showView addSubview:tempIcon];
  448. tempIcon.sd_layout
  449. .leftSpaceToView(showView, (showView.width/2)-(NOimg.size.width/4.0f))
  450. .topSpaceToView(showView, (showView.height/2)-100.0f-(NOimg.size.height/4.0f))
  451. .widthIs(NOimg.size.width/2.0f)
  452. .heightIs(NOimg.size.height/2.0f);
  453. UILabel *tipLab = [UILabel new];
  454. [showView addSubview:tipLab];
  455. [tipLab setText:text];
  456. [tipLab setTextAlignment:NSTextAlignmentCenter];
  457. [tipLab setTextColor:NewLightGrayColor];
  458. [tipLab setBackgroundColor:NewClearColor];
  459. [tipLab setFont:NewAutoFont(16.0)];
  460. tipLab.sd_layout
  461. .leftEqualToView(showView)
  462. .rightEqualToView(showView)
  463. .topSpaceToView(tempIcon,10)
  464. .heightIs(20.0);
  465. if (buttonText.length>0) {
  466. UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
  467. [showView addSubview:button];
  468. [button setTitle:buttonText forState:UIControlStateNormal];
  469. [button setTitleColor:NewNavigationColor forState:UIControlStateNormal];
  470. ViewBorderRadius(button, 16, 2, NewNavigationColor);
  471. [button addTarget:self action:@selector(reloadingData) forControlEvents:UIControlEventTouchUpInside];
  472. CGFloat width = [NewUtils heightforString:[NSString stringWithFormat:@"%@",buttonText] andHeight:34 fontSize:16];
  473. button.sd_layout
  474. .leftSpaceToView(showView, (showView.width/2)-((width+35)/2))
  475. .topSpaceToView(tipLab, 30.0)
  476. .widthIs(width+35)
  477. .heightIs(34);
  478. }
  479. }
  480. [UIView beginAnimations:@"ShowArrow" context:nil];
  481. [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
  482. [UIView setAnimationDuration:0.25f];
  483. [UIView setAnimationDelegate:self];
  484. [showView setAlpha:1.0f];
  485. [UIView commitAnimations];
  486. }
  487. - (void)hideReloadingview
  488. {
  489. [UIView animateWithDuration:0.25 animations:^{
  490. showView.hidden = YES;
  491. } completion:^(BOOL finished) {
  492. for (id obj in showView.subviews) {
  493. [obj removeFromSuperview];
  494. }
  495. showView = nil;
  496. [showView removeFromSuperview];
  497. }];
  498. }
  499. //搜索虚拟键盘响应
  500. - (BOOL)textFieldShouldReturn:(UITextField *)textField
  501. {
  502. NSLog(@"点击了搜索");
  503. [textField resignFirstResponder];
  504. [self networkRequest:nil Shijian:timeOrhaoping Sousuo:textField.text GuWentype:guwentype];
  505. return YES;
  506. }
  507. - (void)didReceiveMemoryWarning {
  508. [super didReceiveMemoryWarning];
  509. // Dispose of any resources that can be recreated.
  510. }
  511. /*
  512. #pragma mark - Navigation
  513. // In a storyboard-based application, you will often want to do a little preparation before navigation
  514. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  515. // Get the new view controller using [segue destinationViewController].
  516. // Pass the selected object to the new view controller.
  517. }
  518. */
  519. @end