CommunityCell.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. #import "CommunityCell.h"
  2. #import "LoginViewController.h"
  3. //#import "MJPhotoBrowser.h"
  4. //#import "MJPhoto.h"
  5. #import "DiaryVC.h"
  6. //表示风格1的cell最多10张。竖着排列
  7. #define imgCntMax 10
  8. static CommunityCell *selfCell;
  9. @interface CommunityCell()
  10. {
  11. UILabel* lblHead;
  12. UILabel* lblContent;
  13. UILabel* lblTag;
  14. UILabel* lblAddr;
  15. NSMutableArray* btns;
  16. NSInteger imgCnt;
  17. NSArray *urls;
  18. /**头像按钮。点击该按钮后,将会跳转到该用户的学车日记
  19. */
  20. UIButton* prtBtn;
  21. }
  22. @property(nonatomic,strong)NSMutableArray* imgs;
  23. @property(assign)NSInteger style;
  24. @end
  25. @implementation CommunityCell
  26. @synthesize imgs;
  27. - (void)awakeFromNib {
  28. [super awakeFromNib];
  29. // Initialization code
  30. }
  31. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  32. [super setSelected:selected animated:animated];
  33. }
  34. #pragma mark -
  35. -(instancetype)initWithStyle:(UITableViewCellStyle)st reuseIdentifier:(NSString *)reuseIdentifier
  36. {
  37. self = [super initWithStyle:st reuseIdentifier:reuseIdentifier];
  38. if (self) {
  39. selfCell = self;
  40. UILabel* label;
  41. label = [[UILabel alloc] init];
  42. [self addSubview:label];
  43. lblAddr = label;
  44. label = [[UILabel alloc] init];
  45. label.numberOfLines = 0;
  46. [self addSubview:label];
  47. lblContent = label;
  48. label = [[UILabel alloc] init];
  49. [self addSubview:label];
  50. lblHead = label;
  51. label = [[UILabel alloc] init];
  52. [self addSubview:label];
  53. lblTag = label;
  54. _acceptLabel = [[UILabel alloc] init];
  55. _acceptLabel.textAlignment = NSTextAlignmentCenter;
  56. _acceptLabel.hidden = YES;
  57. [self addSubview:_acceptLabel];
  58. NSInteger tag = 0;
  59. btns = [NSMutableArray array];
  60. UIButton* btn;
  61. btn = [[UIButton alloc] init];
  62. [btn.imageView setContentMode:UIViewContentModeScaleAspectFit];
  63. [self addSubview:btn];
  64. [btns addObject:btn];
  65. [btn setTag:tag++];
  66. btn = [[UIButton alloc] init];
  67. [btn.imageView setContentMode:UIViewContentModeScaleAspectFit];
  68. [self addSubview:btn];
  69. [btns addObject:btn];
  70. [btn setTag:tag++];
  71. btn = [[UIButton alloc] init];
  72. [self addSubview:btn];
  73. [btn setTag:tag++];
  74. prtBtn = btn;
  75. [btn target:self];
  76. [lblHead borderColor:RGB_COLOR(229, 160, 161) width:1 cornorRadios:3];
  77. lblHead.textColor = RGB_COLOR(219, 113, 116);
  78. lblHead.layer.borderColor =RGB_COLOR(229, 160, 161).CGColor;
  79. lblHead.backgroundColor = RGB_COLOR(251, 241, 241);
  80. [lblContent setTextColor:kTitleColor];
  81. [lblContent setFont:[UIFont scaleSize:NormalFont]];
  82. [lblHead setFont:[UIFont scaleSize:12]];
  83. lblHead.textAlignment = NSTextAlignmentCenter;
  84. [lblTag setFont:[UIFont scaleSize:13]];
  85. [lblTag setTextColor:defGreen];
  86. lblTag.textAlignment = NSTextAlignmentCenter;
  87. lblTag.layer.borderColor = defGreen.CGColor;
  88. lblTag.layer.masksToBounds = YES;
  89. lblTag.layer.borderWidth = 1;
  90. lblTag.numberOfLines = 0;
  91. [lblAddr setFont:[UIFont scaleSize:13]];
  92. [lblAddr setTextColor:contentTextColor];
  93. [btns[0] addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  94. [btns[1] addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  95. [btns[0] setImage:[UIImage imageNamed:@"community0.png"] forState:UIControlStateNormal];
  96. [btns[0] setImage:[UIImage imageNamed:@"community1.png"] forState:UIControlStateSelected];
  97. [btns[1] setImage:[UIImage imageNamed:@"community2.png"] forState:UIControlStateNormal];
  98. [lblHead setText:@"置顶"];
  99. }
  100. return self;
  101. }
  102. +(CommunityCell*)cellForTableView:(UITableView*)tableView Style:(NSInteger)st
  103. {
  104. NSString* cellid;
  105. cellid= @"CommunityCellIdentifier";
  106. CommunityCell* cell = [tableView dequeueReusableCellWithIdentifier:cellid];
  107. if (!cell) {
  108. cell = [[CommunityCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellid];
  109. cell.style = st;
  110. cell.imgs = [NSMutableArray array];
  111. //普通风格0的cell最多3张图,横着排列。风格1的cell最多10张。竖着排列
  112. int cnt = 0;
  113. switch (st) {
  114. case 0:
  115. case 2:
  116. cnt = 3;
  117. break;
  118. case 1:
  119. cnt = imgCntMax;
  120. break;
  121. default:
  122. break;
  123. }
  124. for (int i =0; i<cnt; i++) {
  125. UIImageView* iv;
  126. iv = [[UIImageView alloc] init];
  127. /*
  128. UIViewContentModeScaleToFill根据屏幕拉宽
  129. UIViewContentModeScaleAspectFit原大小
  130. UIViewContentModeScaleAspectFill放大获取合适的宽 只是长被裁减了
  131. */
  132. // 内容模式
  133. [iv setContentMode:UIViewContentModeScaleAspectFit];
  134. iv.layer.masksToBounds = YES;
  135. if (st == 1) {
  136. // 事件监听 这是详情里边的 最多九张图
  137. iv.tag = i;
  138. iv.userInteractionEnabled = YES;
  139. [iv addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:selfCell action:@selector(tapImage:)]];
  140. iv.clipsToBounds = YES;
  141. iv.contentMode = UIViewContentModeScaleAspectFit;
  142. }
  143. [cell addSubview:iv];
  144. [cell.imgs addObject:iv];
  145. }
  146. [cell setBackgroundColor:[UIColor clearColor]];
  147. [cell.textLabel setTextColor:kTitleColor];
  148. [cell.detailTextLabel setTextColor:contentTextColor];
  149. cell.imageView.layer.masksToBounds = YES;
  150. }
  151. return cell;
  152. }
  153. -(void)tapImage:(UITapGestureRecognizer *)tap
  154. {
  155. //隐藏键盘
  156. if (self.block) {
  157. self.block();
  158. }
  159. [RQ_SHARE_FUNCTION showPhotoBrowserWithDataSource:urls currentIndex:tap.view.tag isCanSave:YES];
  160. }
  161. //这个方法总是执行两次 不晓得什么情况 不过现在不影响了
  162. -(void)setModel:(NSDictionary *)model
  163. {
  164. _model = model;
  165. urls = [model[@"PICTURES"] componentsSeparatedByString:@","];
  166. // NSLog(@"urls->%@",urls);
  167. int i =0;
  168. imgCnt = 0;
  169. for (NSString* obj in urls) {
  170. if ([obj isEqualToString:@""]) {
  171. break;
  172. }
  173. NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
  174. //图片路径 总是变化 算了 这里做个判断
  175. NSString *str = [obj stringByTrimmingCharactersInSet:whitespace];
  176. if (str && ![str hasPrefix:@"http"]){
  177. str = [imgPreFix stringByAppendingString:[obj stringByTrimmingCharactersInSet:whitespace]];
  178. }
  179. if ( 0 == _style || 2 == _style ) {
  180. if (i < 3) {
  181. //dansonimg
  182. [imgs[i++] sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"btn.png"]];
  183. }
  184. }else if( 1 == _style){
  185. if (i < imgCntMax) {
  186. //dansonimg
  187. [imgs[i++] sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"btn.png"]];
  188. }
  189. }
  190. imgCnt++;
  191. }
  192. NSString *str = model[@"HEADIMG"];
  193. if (str && ![str hasPrefix:@"http"]){
  194. str = [imgPreFix stringByAppendingString:str];
  195. }
  196. if (!str) {
  197. str = @"";
  198. }
  199. [self.imageView sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:randomPortrait()];
  200. [self.textLabel setText:model[@"TI_CRUSERNAME"]];
  201. //搞定 HH是24格式的时间 hh是12小时
  202. NSString *timeString = model[@"TI_CRDATE"];
  203. NSDateFormatter *formatter = [NSDateFormatter rq_defaultDateFormatter];
  204. NSDate *timeDate = [formatter dateFromString:timeString];
  205. NSDate *date = [NSDate date];
  206. NSTimeInterval timeStamp= [date timeIntervalSinceDate:timeDate];
  207. int time = timeStamp;
  208. NSString *viewDate = model[@"TI_CRDATE"];
  209. if (time > 0)
  210. {
  211. int second = time%60;
  212. int min = time/60;
  213. int hour = min/60;
  214. min = min%60;
  215. int day = hour/24;
  216. hour = hour%24;
  217. if (day > 0)
  218. {
  219. viewDate = [NSString stringWithFormat:@"%d天前",day];
  220. if (day > 29)
  221. {
  222. viewDate = @"一个月前";
  223. }
  224. if (day > 59)
  225. {
  226. viewDate = [model[@"TI_CRDATE"] substringToIndex:10];
  227. }
  228. }
  229. else
  230. {
  231. if (hour > 0)
  232. {
  233. viewDate = [NSString stringWithFormat:@"%d小时前",hour];
  234. }
  235. else
  236. {
  237. if (min > 0)
  238. {
  239. viewDate = [NSString stringWithFormat:@"%d分钟前",min];
  240. }
  241. else
  242. {
  243. if (second > 10)
  244. {
  245. viewDate = [NSString stringWithFormat:@"%d秒前",second];
  246. }
  247. else
  248. {
  249. viewDate = @"刚刚";
  250. }
  251. }
  252. }
  253. }
  254. }
  255. //NSLog(@"时间---->%@--------viewDate----->%@",model[@"TI_CRDATE"],viewDate);
  256. self.detailTextLabel.text = viewDate;
  257. lblHead.hidden = ! [model[@"ISTOP"] integerValue];
  258. if ([model[@"ISTOP"] integerValue]) {
  259. [lblContent setText:[@" " stringByAppendingString: model[@"CONTENT"] ]];
  260. }else{
  261. [lblContent setText: model[@"CONTENT"] ];
  262. }
  263. if ([model[@"ISPOINT"] intValue])
  264. {
  265. [btns[0] setSelected:YES];
  266. }else{
  267. [btns[0] setSelected:NO];
  268. }
  269. [btns[0] setTitle:model[@"POINTNUMFROM"] textColor:contentTextColor font:13 fotState:UIControlStateNormal];
  270. [btns[1] setTitle:model[@"COMMENTNUM"] textColor:contentTextColor font:13 fotState:UIControlStateNormal];
  271. str = model[@"GROUPNAME"];
  272. if (!str || [str isEqualToString:@""]) {
  273. str = @"吐槽";
  274. }
  275. [lblTag setText:str];
  276. NSString *cityStr = model[@"CITY"];
  277. if (!cityStr) {
  278. cityStr = @"";
  279. }
  280. NSString *jxmcStr = model[@"JXMC"];
  281. if (!jxmcStr) {
  282. jxmcStr = @"";
  283. }
  284. [lblAddr setText:[NSString stringWithFormat:@"%@ %@",cityStr,jxmcStr]];
  285. // if ( 1 == [model[@"TI_TYPE"] intValue]) {
  286. // lblTag.hidden = NO;
  287. // }else{
  288. // lblTag.hidden = YES;
  289. // }
  290. }
  291. /**【置顶】2个字。可以在前面添加3个一字占位。然后再上面添加一个label;
  292. */
  293. -(void)layoutSubviews
  294. {
  295. [super layoutSubviews];
  296. //NSLog(@"%d",(int)_style);
  297. //TI_TYPE = 4 是学车问答
  298. switch (_style) {
  299. case 0:
  300. //话题
  301. [self layoutStyle0];
  302. break;
  303. case 1:
  304. //话题详情
  305. [self layoutStyle1];
  306. break;
  307. case 2:
  308. [self layoutStyle2];
  309. break;
  310. default:
  311. break;
  312. }
  313. }
  314. -(void)layoutStyle1
  315. {
  316. CGFloat wid = self.frame.size.width;
  317. CGFloat x,y,w,h,bd;
  318. bd = 10;
  319. w = h = 50;
  320. x = y = bd;
  321. prtBtn.frame = self.imageView.frame = CGRectMake(x, y, w, h);
  322. self.imageView.layer.cornerRadius = w/2.0;
  323. x += bd+w;
  324. w = wid - x - bd;
  325. h /= 2.0;
  326. self.textLabel.frame =CGRectMake(x, y, w, h);
  327. y+= h;
  328. self.detailTextLabel.frame =CGRectMake(x, y, w, h);
  329. x = bd;
  330. w = wid - 2*bd;
  331. y += bd + h;
  332. h = [lblContent.text heightForWid:w Font:NormalFont]+bd;
  333. lblContent.frame =CGRectMake(x, y, w, h);
  334. lblHead.frame =CGRectMake(x+1, y+3, [lblHead.text sizeForFont:13].width+6,[lblHead.text sizeForFont:13].height+3);
  335. y += bd + h;
  336. if (imgCnt > 0) {
  337. w = wid - 2* bd;
  338. h = w * 1.0;
  339. }
  340. for (int i =0; i < imgCntMax; i++) {
  341. UIView* v = imgs[i];
  342. v.frame =CGRectMake(x, y, w, h);
  343. if (i < imgCnt) {
  344. y += h + bd;
  345. v.hidden = NO;
  346. }else{
  347. v.hidden = YES;
  348. }
  349. }
  350. x = bd;
  351. h = 20;
  352. w = [lblTag.text sizeForFont:13].width+15;
  353. lblTag.frame =CGRectMake(x, y, w, h);
  354. lblTag.layer.cornerRadius = h/2.0;
  355. if (_showTag) {
  356. x += w+bd;
  357. lblTag.hidden = NO;
  358. }else{
  359. lblTag.hidden = YES;
  360. }
  361. w = kSize.width - 200;
  362. lblAddr.frame =CGRectMake(x, y, w, h);
  363. for (UIView* v in btns) {
  364. v.hidden = YES;
  365. }
  366. }
  367. -(void)layoutStyle2
  368. {
  369. CGFloat wid = self.frame.size.width;
  370. CGFloat x,y,w,h,bd;
  371. bd = 10;
  372. w = h = 50;
  373. x = y = bd;
  374. self.imageView.frame = CGRectMake(x, y, w, h);
  375. self.imageView.layer.cornerRadius = w/2.0;
  376. self.imageView.hidden = YES;
  377. self.textLabel.hidden = YES;
  378. self.detailTextLabel.hidden = YES;
  379. prtBtn.hidden = YES;
  380. x += bd+w;
  381. w = wid - x - bd;
  382. h /= 2.0;
  383. self.textLabel.frame =CGRectMake(x, y, w, h);
  384. y+= h;
  385. self.detailTextLabel.frame =CGRectMake(x, y, w, h);
  386. x = bd;
  387. w = wid - 2*bd;
  388. y = bd ;
  389. h = [lblContent.text heightForWid:w Font:NormalFont]+bd;
  390. lblContent.frame =CGRectMake(x, y, w, h);
  391. lblHead.frame =CGRectMake(x+1, y+3, [lblHead.text sizeForFont:13].width+6,[lblHead.text sizeForFont:13].height+3);
  392. if (imgCnt > 0) {
  393. y += bd + h;
  394. h = w = (wid - bd*4)/3.0;
  395. }
  396. int i = 0;
  397. for (UIView* v in imgs) {
  398. v.frame =CGRectMake(x, y, w, h);
  399. x += w+bd;
  400. if (i < imgCnt) {
  401. v.hidden = NO;
  402. }else{
  403. v.hidden = YES;
  404. }
  405. i ++;
  406. }
  407. y += bd + h;
  408. x = bd;
  409. h = 20;
  410. // y = hei - h - bd;
  411. w = [lblTag.text sizeForFont:13].width+15;
  412. lblTag.frame =CGRectMake(x, y, w, h);
  413. lblTag.layer.cornerRadius = h/2.0;
  414. if (_showTag) {
  415. x += w+bd;
  416. lblTag.hidden = NO;
  417. }else{
  418. lblTag.hidden = YES;
  419. }
  420. w = kSize.width - 200;
  421. lblAddr.frame =CGRectMake(x, y, w, h);
  422. h = 30;
  423. // y = hei - h - bd;
  424. w = h*2.5;
  425. x = wid - bd - w;
  426. UIButton* btn;
  427. btn = btns[1];
  428. btn.frame =CGRectMake(x, y, w, h);
  429. x -= (bd + w );
  430. btn = btns[0];
  431. btn.frame =CGRectMake(x, y, w, h);
  432. }
  433. -(void)layoutStyle0
  434. {
  435. CGFloat wid = self.frame.size.width;
  436. CGFloat x,y,w,h,bd;
  437. bd = 10;
  438. w = h = 50;
  439. x = y = bd;
  440. prtBtn.frame = self.imageView.frame = CGRectMake(x, y, w, h);
  441. self.imageView.layer.cornerRadius = w/2.0;
  442. x += bd+w;
  443. w = wid - x - bd;
  444. h /= 2.0;
  445. self.textLabel.frame =CGRectMake(x, y, w-100, h);
  446. y+= h;
  447. self.detailTextLabel.frame =CGRectMake(x, y, w, h);
  448. _acceptLabel.hidden = NO;
  449. _acceptLabel.frame = CGRectMake(kFrame.size.width - 90, y - h, 65, h);
  450. x = bd;
  451. w = wid - 2*bd;
  452. y += bd + h;
  453. h = [lblContent.text heightForWid:w Font:NormalFont]+bd;
  454. lblContent.frame =CGRectMake(x, y, w, h);
  455. lblHead.frame =CGRectMake(x+1, y+3, [lblHead.text sizeForFont:13].width+6,[lblHead.text sizeForFont:13].height+3);
  456. if (imgCnt > 0) {
  457. y += bd + h;
  458. h = w = (wid - bd*4)/3.0;
  459. }
  460. int i = 0;
  461. for (UIView* v in imgs) {
  462. v.frame =CGRectMake(x, y, w, h);
  463. x += w+bd;
  464. if (i < imgCnt) {
  465. v.hidden = NO;
  466. }else{
  467. v.hidden = YES;
  468. }
  469. i ++;
  470. }
  471. y += bd + h;
  472. x = bd;
  473. h = 20;
  474. // y = hei - h - bd;
  475. w = [lblTag.text sizeForFont:13].width+15;
  476. lblTag.frame =CGRectMake(x, y, w, h);
  477. lblTag.layer.cornerRadius = h/2.0;
  478. // if (!lblTag.hidden) {
  479. // x += w+bd;
  480. // }
  481. if (_showTag) {
  482. x += w+bd;
  483. lblTag.hidden = NO;
  484. }else{
  485. lblTag.hidden = YES;
  486. }
  487. w = kSize.width - 200;
  488. lblAddr.frame =CGRectMake(x, y, w, h);
  489. h = 30;
  490. // y = hei - h - bd;
  491. w = h*2.5;
  492. x = wid - bd - w;
  493. UIButton* btn;
  494. btn = btns[1];
  495. btn.frame =CGRectMake(x, y, w, h);
  496. x -= (bd + w );
  497. btn = btns[0];
  498. btn.frame =CGRectMake(x, y, w, h);
  499. }
  500. -(void)btnClick:(UIButton*)sender
  501. {
  502. if (self.block) {
  503. self.block();
  504. }
  505. if ( 0 == sender.tag) {
  506. if (!myDelegate.isLogin) {
  507. LoginViewController* vc = [[LoginViewController alloc] init];
  508. vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  509. if (_delegate) {
  510. vc.modalPresentationStyle = UIModalPresentationFullScreen;
  511. [(UIViewController*)_delegate presentViewController:vc animated:YES completion:nil];
  512. }
  513. return;
  514. }
  515. int pointNum = [[btns[0] titleForState:UIControlStateNormal] intValue];
  516. if (sender.selected) {
  517. [(UIButton *)btns[0] setTitle:[NSString stringWithFormat:@"%d",pointNum -1] forState:UIControlStateNormal];
  518. //didDePoint
  519. if ([_delegate respondsToSelector:@selector(didDePoint:)]) {
  520. [_delegate didDePoint:_model];
  521. }
  522. }else{
  523. [(UIButton *)btns[0] setTitle:[NSString stringWithFormat:@"%d",pointNum+1] forState:UIControlStateNormal];
  524. if ([_delegate respondsToSelector:@selector(didPoint:)]) {
  525. [_delegate didPoint:_model];
  526. }
  527. }
  528. sender.selected = !sender.selected;
  529. }
  530. if( 1 == sender.tag){
  531. if ([_delegate respondsToSelector:@selector(gotoComment:)]) {
  532. [_delegate gotoComment:_model[@"ID"]];
  533. }
  534. }
  535. if (2 == sender.tag) {
  536. if (_delegate) {
  537. DiaryVC* vc = [DiaryVC new];
  538. NSString *cruser = _model[@"TI_CRUSER"];
  539. if (!cruser || cruser.length == 0) {
  540. cruser = _model[@"CRUSER"];
  541. }
  542. vc.userID = cruser;
  543. [(UIViewController*)_delegate navPushHideTabbarToVC:vc];
  544. }
  545. }
  546. }
  547. @end
  548. CGFloat communityCellHeight(NSDictionary* dict , NSInteger type)
  549. {
  550. CGFloat wid = kSize.width;
  551. CGFloat bd = 10;
  552. if (0 == type) {
  553. NSString* str = dict[@"CONTENT"];
  554. if (!str) {
  555. str = @"";
  556. }
  557. CGFloat contentH = [str heightForWid:(kSize.width - 20) Font:NormalFont] + 15;
  558. str = dict[@"PICTURES"];
  559. CGFloat imgH ;
  560. if (!str || [str isEqualToString:@""]) {
  561. imgH = 0;
  562. }else{
  563. imgH = (wid - bd*4)/3.0;
  564. }
  565. return 120 + contentH + imgH;
  566. }
  567. if (2 == type) {
  568. NSString* str = dict[@"CONTENT"];
  569. if (!str) {
  570. str = @"";
  571. }
  572. CGFloat contentH = [str heightForWid:(kSize.width - 20) Font:NormalFont] + 15;
  573. str = dict[@"PICTURES"];
  574. if (!str) {
  575. str = @"";
  576. }
  577. CGFloat imgH ;
  578. if ([str isEqualToString:@""]) {
  579. imgH = 0;
  580. }else{
  581. imgH = (wid - bd*4)/3.0;
  582. }
  583. return 60 + contentH + imgH;
  584. }
  585. if (1 == type) {
  586. NSString* str = dict[@"CONTENT"];
  587. if (!str) {
  588. str = @"";
  589. }
  590. CGFloat contentH = [str heightForWid:(kSize.width - 20) Font:NormalFont] + 15;
  591. str = dict[@"PICTURES"];
  592. if (!str) {
  593. str = @"";
  594. }
  595. CGFloat imgH ;
  596. if ([str isEqualToString:@""]) {
  597. imgH = 0;
  598. }else{
  599. NSArray *urls = [str componentsSeparatedByString:@","];
  600. imgH = urls.count * (bd + (kSize.width - bd*2)*1.0);
  601. }
  602. return 120 + contentH + imgH;
  603. }
  604. return 400;
  605. }
  606. /**总共9个subView 其中1个是数组
  607. 前3个用cell自带的。后面的自己写.
  608. 下次复制的时候,首先就要把不同的地方改过来,然后再去修改个性化数据。
  609. */