SelectorViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. //
  2. // SelectorViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 8/3/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "SelectorViewController.h"
  9. #import "iSalesNetwork.h"
  10. @interface SelectorViewController ()
  11. @end
  12. @implementation SelectorViewController
  13. @synthesize selectordelegate;
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view.
  17. }
  18. - (void)viewWillAppear:(BOOL)animated
  19. {
  20. [super viewWillAppear:animated];
  21. self.view.superview.layer.cornerRadius
  22. = 0;
  23. }
  24. - (void)didReceiveMemoryWarning {
  25. [super didReceiveMemoryWarning];
  26. // Dispose of any resources that can be recreated.
  27. }
  28. /*
  29. #pragma mark - Navigation
  30. // In a storyboard-based application, you will often want to do a little preparation before navigation
  31. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  32. // Get the new view controller using [segue destinationViewController].
  33. // Pass the selected object to the new view controller.
  34. }
  35. */
  36. #pragma mark - Table view data source
  37. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  38. //{
  39. // return 0;
  40. //}
  41. //- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  42. //{
  43. // return 0;
  44. //}
  45. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  46. //{
  47. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  48. // return myView;
  49. //
  50. //}
  51. //- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
  52. //{
  53. // UIView* myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 0.0001)];
  54. //// myView.backgroundColor = [UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7];
  55. //// UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 22)];
  56. //// titleLabel.textColor=[UIColor whiteColor];
  57. //// titleLabel.backgroundColor = [UIColor clearColor];
  58. //// if(section==0)
  59. //// titleLabel.text=NSLocalizedString(@"display_items", nil);
  60. //// else
  61. //// titleLabel.text=NSLocalizedString(@"hide_items", nil);
  62. //// [titleLabel sizeToFit];
  63. //// [myView addSubview:titleLabel];
  64. ////
  65. // return myView;
  66. //}
  67. //- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
  68. // if(section==0)
  69. // return nil;
  70. //
  71. // NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
  72. // if(related_json==nil)
  73. // {
  74. // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%d",section-1]];
  75. // return [section_json valueForKey:@"title"] ;
  76. // }
  77. // else
  78. // {
  79. // if(section==1)
  80. // return @"related model";
  81. // else
  82. // {
  83. // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%d",section-2]];
  84. // return [section_json valueForKey:@"title"] ;
  85. // }
  86. // }
  87. //}
  88. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  89. {
  90. return 1;
  91. }
  92. //- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
  93. //{
  94. // DebugLog(@"canMoveRowAtIndexPath");
  95. //
  96. // if([tableView numberOfRowsInSection:indexPath.section]>1)
  97. // return true;
  98. // else
  99. // return false;
  100. //}
  101. //- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
  102. //{
  103. // NSMutableArray * from;
  104. // NSMutableArray * to ;
  105. // if(fromIndexPath.section==0)
  106. // from = self.displayfields;
  107. // else
  108. // from = self.hidefields;
  109. // if(toIndexPath.section==0)
  110. // to = self.displayfields;
  111. // else
  112. // to = self.hidefields;
  113. // id content=from[fromIndexPath.row];
  114. // [from removeObjectAtIndex:fromIndexPath.row];
  115. // [to insertObject:content atIndex:toIndexPath.row];
  116. //
  117. // [tableView reloadData];
  118. //
  119. //}
  120. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  121. {
  122. return [[self.selector valueForKey:@"count"] intValue];
  123. //
  124. // if(section==0)
  125. // return 1;
  126. // NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
  127. // if(related_json==nil)
  128. // {
  129. // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%d",section-1]];
  130. // return [[section_json valueForKey:@"count"] intValue];
  131. // }
  132. // else
  133. // {
  134. // if(section==1)
  135. // return 1;
  136. // else
  137. // {
  138. // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%d",section-2]];
  139. // return [[section_json valueForKey:@"count"] intValue];
  140. // }
  141. // }
  142. //
  143. }
  144. //- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
  145. //{
  146. // return UITableViewCellEditingStyleNone;
  147. //}
  148. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  149. {
  150. //如果两次点击的时间间隔小于1秒,则断定为双击事件
  151. NSDictionary* item = [self.selector objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  152. NSDictionary* params = [item objectForKey:@"params"];
  153. NSString* detail_id=[[[params objectForKey:@"param_0"] valueForKey:@"val" ] stringValue];
  154. // NSString* category=[self.selector objectForKey:[NSString stringWithFormat:@"item_%ld",indexPath.row]] valueForKey:<#(NSString *)#>
  155. [selectordelegate selected:detail_id category:nil];
  156. [self dismissViewControllerAnimated:false completion:^{}];
  157. //
  158. // if(tableView.editing==false)
  159. // return;
  160. }
  161. //
  162. //
  163. // if([tableView numberOfRowsInSection:indexPath.section]<=1)
  164. // return;
  165. // // int between = 1;
  166. // NSUInteger curr = [[NSDate date] timeIntervalSince1970];
  167. //
  168. // if(indexPath.row==self.lasttap.row&&indexPath.section==self.lasttap.section)
  169. // {
  170. // if (curr-self.taptime<1) {
  171. // DebugLog(@"double click!");
  172. // self.lasttap =nil;
  173. //
  174. // NSMutableArray * from;
  175. // NSMutableArray * to ;
  176. // int section;
  177. // if(indexPath.section==0)
  178. // {
  179. // from = self.displayfields;
  180. // to = self.hidefields;
  181. // section = 1;
  182. // }
  183. // else
  184. // {
  185. //
  186. // from = self.hidefields;
  187. // to = self.displayfields;
  188. // section = 0;
  189. // }
  190. // NSIndexPath * toIndexPath = [NSIndexPath indexPathForRow:0 inSection:section];
  191. // // NSIndexPath * headerIndexPath = [NSIndexPath indexPathForRow:0 inSection:indexPath.section];
  192. // // NSIndexPath * headerIndexPath1 = toIndexPath;
  193. //
  194. // id content=from[indexPath.row];
  195. // [tableView beginUpdates];
  196. // [from removeObjectAtIndex:indexPath.row];
  197. // [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
  198. //
  199. // [to insertObject:content atIndex:0];
  200. // [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:toIndexPath] withRowAnimation:UITableViewRowAnimationFade];
  201. // [tableView endUpdates];
  202. //
  203. // // [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath] withRowAnimation:UITableViewRowAnimationFade];
  204. // // [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:headerIndexPath1] withRowAnimation:UITableViewRowAnimationFade];
  205. // [tableView reloadData];
  206. //
  207. //
  208. // }
  209. // self.taptime = curr;
  210. //
  211. //
  212. // }
  213. // else
  214. // {
  215. // self.taptime = curr;
  216. // self.lasttap = indexPath;
  217. // }
  218. //}
  219. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  220. {
  221. return 70;
  222. // SelectorCell
  223. // if(indexPath.section ==0)
  224. // return 550;
  225. //
  226. // NSDictionary* related_json = [self.detail_data objectForKey:@"related_model"];
  227. // if(related_json==nil)
  228. // {
  229. // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%d",indexPath.section-1]];
  230. //
  231. // NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
  232. //
  233. // NSString* type=[section_json valueForKey:@"type"] ;
  234. //
  235. // if([type isEqualToString:@"kv"])
  236. // {
  237. // float width = tableView.frame.size.width;
  238. // width-=CELL_MARGIN*2;
  239. // CGSize constraintkey = CGSizeMake(width*0.4-2*LABEL_MARGIN, 20000.0f);//key label width is 40% cell width;
  240. // CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
  241. //
  242. //
  243. //
  244. // // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
  245. // NSString* key =[item_json valueForKey:@"key"] ;
  246. //
  247. // // [cell.keyLabel sizeToFit];
  248. // NSString* val=[item_json valueForKey:@"val"] ;
  249. //
  250. // if([val isEqual:[NSNull null]])
  251. // val=@"";
  252. // if(val==nil)
  253. // val=@"";
  254. // if([val isEqualToString:@"null"])
  255. // val=@"";
  256. //
  257. //
  258. //
  259. // CGRect frame;
  260. // frame.size = constraintval;
  261. // frame.origin.x=0;
  262. // frame.origin.y=0;
  263. // RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
  264. // [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
  265. // // rtlabel.lineSpacing = 20.0;
  266. // [rtlabel setText: val];
  267. // CGSize sizeval=rtlabel.optimumSize;
  268. //
  269. //
  270. // CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  271. // // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
  272. // float height = MAX(sizekey.height,sizeval.height);
  273. // height = MAX(height+LINE_WIDTH, DEF_CELL_HEIGHT);
  274. //
  275. //
  276. // return height;
  277. // }
  278. // else if([type isEqualToString:@"img"])
  279. // {
  280. // int img_count = [[item_json valueForKey:@"count"] intValue];
  281. // double ret = 0;
  282. // for(int j=0;j<img_count;j++)
  283. // {
  284. // NSDictionary* img_json =[item_json objectForKey:[NSString stringWithFormat:@"image_%d",j ]];
  285. // float width = [[img_json valueForKey:@"width"]floatValue];
  286. // float height = [[img_json valueForKey:@"height"]floatValue];
  287. // ret+=height*tableView.bounds.size.width / width;
  288. // }
  289. //
  290. // return ret;
  291. // }
  292. // else if([type isEqualToString:@"content"])
  293. // return 270;
  294. // return 44;
  295. // }
  296. // else
  297. // {
  298. // if(indexPath.section==1)
  299. // return 270;
  300. // else
  301. // {
  302. // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%d",indexPath.section-2]];
  303. //
  304. // NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
  305. //
  306. // NSString* type=[section_json valueForKey:@"type"] ;
  307. //
  308. // if([type isEqualToString:@"kv"])
  309. // {
  310. // float width = tableView.frame.size.width;
  311. // width-=CELL_MARGIN*2;
  312. // CGSize constraintkey = CGSizeMake(width*0.4-2*LABEL_MARGIN, 20000.0f);//key label width is 40% cell width;
  313. // CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
  314. //
  315. //
  316. //
  317. // // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
  318. // NSString* key =[item_json valueForKey:@"key"] ;
  319. //
  320. // // [cell.keyLabel sizeToFit];
  321. // NSString* val=[item_json valueForKey:@"val"] ;
  322. //
  323. // if([val isEqual:[NSNull null]])
  324. // val=@"";
  325. // if(val==nil)
  326. // val=@"";
  327. // if([val isEqualToString:@"null"])
  328. // val=@"";
  329. //
  330. //
  331. //
  332. // CGRect frame;
  333. // frame.size = constraintval;
  334. // frame.origin.x=0;
  335. // frame.origin.y=0;
  336. // RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
  337. // [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
  338. // // rtlabel.lineSpacing = 20.0;
  339. // [rtlabel setText: val];
  340. // CGSize sizeval=rtlabel.optimumSize;
  341. //
  342. //
  343. // CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  344. // // CGSize sizeval = [val sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintval lineBreakMode:NSLineBreakByWordWrapping];
  345. // float height = MAX(sizekey.height,sizeval.height);
  346. // height = MAX(height+LINE_WIDTH, DEF_CELL_HEIGHT);
  347. //
  348. //
  349. // return height;
  350. // }
  351. // else if([type isEqualToString:@"img"])
  352. // {
  353. // int img_count = [[item_json valueForKey:@"count"] intValue];
  354. // double ret = 0;
  355. // for(int j=0;j<img_count;j++)
  356. // {
  357. // NSDictionary* img_json =[item_json objectForKey:[NSString stringWithFormat:@"image_%d",j ]];
  358. // float width = [[img_json valueForKey:@"width"]floatValue];
  359. // float height = [[img_json valueForKey:@"height"]floatValue];
  360. // ret+=height*tableView.bounds.size.width / width;
  361. // }
  362. //
  363. // return ret;
  364. // }
  365. // return 44;
  366. // }
  367. // }
  368. }
  369. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  370. {
  371. // DebugLog(@"cellForRowAtIndexPath");
  372. NSString *CellIdentifier = @"SelectorCell";
  373. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  374. NSDictionary* item = [self.selector objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row]];
  375. cell.imageView.image=[UIImage imageNamed:@"loading_s"];
  376. cell.textLabel.text=[item valueForKey:@"title"];
  377. NSString* img_url = [item valueForKey:@"pic_url"];
  378. NSString* file_name=[img_url lastPathComponent];
  379. NSData* img_data=[iSalesDB load_cached_img:file_name];
  380. if(img_data!=nil)
  381. {
  382. dispatch_async(dispatch_get_main_queue(), ^{
  383. UIImage * img =[UIImage imageWithData:img_data];
  384. cell.imageView.image=img;
  385. });
  386. }
  387. else
  388. {
  389. NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  390. dispatch_async(dispatch_get_main_queue(), ^{
  391. if(downloadimg_data!=nil)
  392. {
  393. [iSalesDB cache_img:downloadimg_data :file_name ];
  394. UIImage * img =[UIImage imageWithData:downloadimg_data];
  395. cell.imageView.image=img;
  396. }
  397. else
  398. cell.imageView.image=[UIImage imageNamed:@"notfound_s"];
  399. });
  400. }
  401. // cell.selector_valLabel.text =[[section_json objectForKey:@"selector"] valueForKey:@"name"];
  402. return cell;
  403. }
  404. // else
  405. // {
  406. // if(indexPath.section==1)
  407. // {
  408. // NSString *CellIdentifier = @"DetailRelatedCell";
  409. //
  410. //
  411. //
  412. // // NSDictionary* section_json = [self.detail_data objectForKey:@"related_model"];
  413. // DetailRelatedCell * cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  414. // cell.itemdelegate = self;
  415. // cell.related_data = related_json;
  416. // return cell;
  417. //
  418. // }
  419. // else
  420. // {
  421. // NSString *CellIdentifier = @"DetailInfoCell";
  422. //
  423. //
  424. //
  425. // NSDictionary* section_json = [self.detail_data objectForKey:[NSString stringWithFormat:@"detail_%d",indexPath.section-2]];
  426. //
  427. // NSDictionary* item_json =[section_json objectForKey:[NSString stringWithFormat:@"item_%ld",(long)indexPath.row ]];
  428. //
  429. // NSString* type=[section_json valueForKey:@"type"] ;
  430. //
  431. // if([type isEqualToString:@"kv"])
  432. // {
  433. // float width = tableView.frame.size.width;
  434. //
  435. // width-=CELL_MARGIN*2;
  436. // CGSize constraintkey = CGSizeMake(width*0.4-2*LABEL_MARGIN, 20000.0f);//key label width is 40% cell width;
  437. // CGSize constraintval = CGSizeMake(width*0.6-2*LABEL_MARGIN, 20000.0f);//val label width is 60% cell width;
  438. // // NSDictionary* item = [self.content get_item_seg:indexPath.section row:indexPath.row];
  439. // NSString* key =[item_json valueForKey:@"key"] ;
  440. //
  441. // NSString* val=[item_json valueForKey:@"val"] ;
  442. // if([val isEqual:[NSNull null]])
  443. // val=@"";
  444. // if(val==nil)
  445. // val=@"";
  446. // if([val isEqualToString:@"null"])
  447. // val=@"";
  448. //
  449. //
  450. //
  451. //
  452. // CGRect frame;
  453. // frame.size = constraintval;
  454. // frame.origin.x=0;
  455. // frame.origin.y=0;
  456. // RTLabel* rtlabel = [[RTLabel alloc] initWithFrame:frame];
  457. // [rtlabel setLineBreakMode: RTTextLineBreakModeWordWrapping];
  458. // // rtlabel.lineSpacing = 20.0;
  459. // [rtlabel setText: val];
  460. // CGSize sizeval=rtlabel.optimumSize;
  461. // CGSize sizekey = [key sizeWithFont:[UIFont systemFontOfSize:17.0] constrainedToSize:constraintkey lineBreakMode:NSLineBreakByWordWrapping];
  462. //
  463. // float height = MAX(sizekey.height,sizeval.height);
  464. // height = MAX(height, DEF_CELL_HEIGHT-LINE_WIDTH);
  465. // sizekey.height = height;
  466. // sizekey.width = constraintkey.width;
  467. // // sizeval.height = height;
  468. // sizeval.width =constraintval.width;
  469. //
  470. // // NSString *CellIdentifier = @"detail_item_kv";
  471. // DetailKVCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  472. // if(cell==nil)
  473. // DebugLog(@"cell is nil.........................");
  474. //
  475. //
  476. //
  477. //
  478. // CGRect framekey = cell.keyLabel.frame;
  479. // framekey.origin.x=CELL_MARGIN+LABEL_MARGIN;
  480. // framekey.origin.y=LINE_WIDTH;
  481. // framekey.size = sizekey;
  482. // cell.keyLabel.frame = framekey;
  483. // cell.keyLabel.text=key;
  484. // CGRect frameval = cell.valLabel.frame;
  485. // frameval.origin.x=constraintkey.width+CELL_MARGIN+3*LABEL_MARGIN; //2 margin for key 1 margin for value self
  486. // frameval.origin.y=LINE_WIDTH;
  487. // frameval.size = sizeval;
  488. // cell.valLabel.frame = frameval;
  489. // // [cell.valLabel setTextAlignment:RTTextAlignmentCenter];
  490. // cell.valLabel.text= val;
  491. // CGPoint rcenter;
  492. // rcenter.x = width * 0.4+width * 0.6/2;
  493. // rcenter.y = height /2;
  494. // cell.valLabel.center=rcenter;
  495. // // cell.valLabel.backgroundColor =[UIColor redColor];
  496. //
  497. // // cell.contentView.superview.backgroundColor = [UIColor clearColor];
  498. // // cell.backgroundColor = [UIColor whiteColor];
  499. // UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
  500. // lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
  501. // lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
  502. // lineview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  503. // [cell.contentView addSubview:lineview];// cell.contentView是个readonly属性,所以别想着替换contentView了.
  504. //
  505. //
  506. //
  507. // return cell;
  508. // }
  509. // else if ([type isEqualToString:@"img"])
  510. // {
  511. // DetailImageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DetailImageCell" forIndexPath:indexPath];
  512. //
  513. // int img_count = [[item_json valueForKey:@"count"] intValue];
  514. // double posy = 0;
  515. // for(int j=0;j<img_count;j++)
  516. // {
  517. // NSDictionary* img_json =[item_json objectForKey:[NSString stringWithFormat:@"image_%d",j ]];
  518. // float width = [[img_json valueForKey:@"width"]floatValue];
  519. // float height = [[img_json valueForKey:@"height"]floatValue];
  520. // //
  521. // UIImageView * imgview = [[UIImageView alloc] initWithFrame:CGRectMake(0, posy, tableView.bounds.size.width , height*tableView.bounds.size.width / width)];
  522. // NSString* img_url = [img_json valueForKey:@"img_url"];
  523. // posy+=height*tableView.bounds.size.width / width;
  524. // NSString* file_name=[img_url lastPathComponent];
  525. // NSData* img_data=[iSalesDB load_cached_img:file_name];
  526. // if(img_data!=nil)
  527. // {
  528. //
  529. // UIImage * img =[UIImage imageWithData:img_data];
  530. // imgview.image = img;
  531. // [cell addSubview:imgview];
  532. // }
  533. // else
  534. // {
  535. //
  536. // dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  537. //
  538. // NSData* downloadimg_data = [NSData dataWithContentsOfURL:[NSURL URLWithString:img_url]];
  539. //
  540. // dispatch_async(dispatch_get_main_queue(), ^{
  541. //
  542. //
  543. //
  544. // if(downloadimg_data!=nil)
  545. // {
  546. // [iSalesDB cache_img:downloadimg_data :file_name ];
  547. //
  548. // UIImage * img =[UIImage imageWithData:downloadimg_data];
  549. // imgview.image = img;
  550. // [cell addSubview:imgview];
  551. // }
  552. //
  553. // });
  554. // });
  555. //
  556. //
  557. // }
  558. //
  559. //
  560. // }
  561. // return cell;
  562. // }
  563. //
  564. // return nil;
  565. //
  566. //
  567. // }
  568. // }
  569. @end