123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // CommentZzVC.m
- // jiaPei
- //
- // Created by EchoShacolee on 2017/2/16.
- // Copyright © 2017年 JCZ. All rights reserved.
- //
- #import "CommentZzVC.h"
- #import "RatingBar.h"
- #import "CommentZzCell.h"
- @interface CommentZzVC ()<UITableViewDelegate,UITableViewDataSource>
- @property (weak, nonatomic) IBOutlet UIView *ratingBar;
- @property (weak, nonatomic) IBOutlet UIView *lableView;
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (weak, nonatomic) IBOutlet UIButton *collectionBtn;
- @property (weak, nonatomic) IBOutlet UIButton *commentBtn;
- @property (nonatomic, retain)NSArray * dataArray;
- @end
- @implementation CommentZzVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- _dataArray = [NSArray new];
- _dataArray = @[@"在俄罗斯西伯利亚的东北部,有一个因极寒而闻名的“世界最冷小村庄”奥伊米亚康",
- @"我的城市开始下起了雪",
- @"我很好奇",
- @"在极寒的条件的人们是如何生活的……请不要告诉我是靠爱在生活……",
- @"在俄罗斯西伯利亚的东北部,有一个因极寒而闻名的“世界最冷小村庄”奥伊米亚康(Oymyakon)。冬天,长达21小时的黑夜,人们在这几乎感受不到白昼"];
- [self myInit];
- [self setTitle:@"评论详情"];
- self.navigationController.navigationBar.translucent = NO;
- [self configNavigationBarDismissNav];
- }
- - (IBAction)collectionBtnClick:(id)sender {
- ShowMsg(@"你知道比悲伤更悲伤的是什么吗?是空欢喜");
- }
- - (IBAction)commentBtnClick:(id)sender {
- ShowMsg(@"正是“要做有趣的人”这一追求的广为流传,使世界上多了好多无趣还很努力的人");
- }
- -(void)myInit
- {
- //ratingBar
- CGSize size = _ratingBar.frame.size;
- RatingBar * starBar = [[RatingBar alloc]initWithFrame:CGRectMake(0, 0, size.width, size.height) Flag:NO];
- starBar.starNumber = 3;
- starBar.enable = NO;
- [_ratingBar addSubview:starBar];
-
- //LableView
- NSArray * falseData = @[@"哇,好漂亮",@"非常有礼貌",@"支付申诉",@"哇好漂亮",@"哇,好",@"有礼貌",@"哇有礼貌漂亮",@"漂亮"];
- NSArray * falseData2 = @[@"5",@"4",@"88",@"5",@"7",@"78",@"35",@"12"];
-
- UILabel * lable;
- CGFloat x = 0;
- CGFloat y = 0;
- CGFloat w = 0;
- CGFloat h = 30;
- CGFloat bd = (kSize.width - 20 - 300)/2+5;
- // CGFloat bd = (_lableView.size.width - )
- for (int i=0;i<falseData.count;i++) {
-
- NSString * contentStr = [NSString stringWithFormat:@" %@ %@ ",falseData[i],falseData2[i]];
- CGSize size =[contentStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:NormalFont]}];
- if (i%3 == 0) {
- x = 0;
- }else{
- x += bd+w;
- }
-
- if (i/3 == 0) {
- y = 5;
- }else{
- if (i%3 == 0) {
- y += 5+h;
- }
- }
-
- w = size.width;
- lable = [[UILabel alloc]setxywh];
-
- [lable setText:contentStr Font:NormalFont TextColor:titleColor Alignment:NSTextAlignmentCenter];
-
- lable.layer.borderWidth = 0.5;
- lable.layer.borderColor = [UIColor grayColor].CGColor;
-
- [_lableView addSubview:lable];
- }
-
-
- //tableView
- _tableView.delegate = self;
- _tableView.dataSource = self;
- [_tableView registerNib:[UINib nibWithNibName:@"CommentZzCell" bundle:nil] forCellReuseIdentifier:@"cellId"];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return _dataArray.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- CGSize size = [_dataArray[indexPath.row] boundingRectWithSize:CGSizeMake(kSize.width-90, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
- return size.height+70+10;//@lee 最后这个加10,我的理解是这个计算的size差了一点类似行间距的东西导致不够显示第二行,估计加5也可以,行数越多,累计误差越大
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- CommentZzCell * cell = [_tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- cell.headImgV.image = [UIImage imageNamed:@"zz.jpg"];
- cell.nameLab.text = @"陈浩南";
- cell.contentLab.text = _dataArray[indexPath.row];
- cell.timeLab.text = @"2017-01-23";
- return cell;
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|