SurveyDetailViewController.m 5.14 KB
Newer Older
n22's avatar
n22 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
//
//  SurveyDetailViewController.m
//  XFFruit
//
//  Created by 陈俊俊 on 15/8/7.
//  Copyright (c) 2015年 Xummer. All rights reserved.
//

#import "SurveyDetailViewController.h"
#import "ResultDetailViewController.h"
#define BottomHeight 50
#define LeftMargin 20
#define LeftWidth 100
#define LeftHeight 30



typedef enum : NSUInteger {
    DetailTag = 6000,
    EndTag,
} BtnTag;

@interface SurveyDetailViewController ()
{
    UIScrollView *_scrollView;
    UIView *_surveyView;
    UIView *_bottomView;
}
@property (nonatomic,strong)UILabel *noteLabel;
@end

@implementation SurveyDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self bulifLayout];
}

#pragma mark - 视图初始化
- (void)bulifLayout{
    self.view.backgroundColor = HexColor(@"f8f8f8");

    _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, ScreenSize.height - 64 - BottomHeight)];
    _scrollView.showsHorizontalScrollIndicator  = NO;
    _scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:_scrollView];
    
    
    UIButton *endBtn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(LeftMargin, ScreenSize.height  - 64 - BottomHeight +5, ScreenSize.width - LeftMargin*2, 40) target:self sel:@selector(btnClick:) tag:EndTag image:nil title:@"结束" titleColor:[UIColor whiteColor] isCorner:YES corner:8 bgColor:HexColor(@"f69100")];
    [self.view addSubview:endBtn];
    

    _surveyView= [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenSize.width, LeftHeight*9+LeftMargin/2)];
    _surveyView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_surveyView];
    
    UILabel *tagLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin/2, 10, LeftWidth*2, LeftHeight)];
    tagLabel.text = @"【调研内容】";
    tagLabel.font =  FontSize(17);
    tagLabel.textColor = [UIColor blueColor];
    [_surveyView addSubview:tagLabel];
    
    NSArray *leftArr = @[@"单号:",@"状态:",@"标题:",@"商品:",@"开始日期:",@"截止日期:",@"调研人员:",@"备注:"];
    NSMutableArray *contentArr = [[NSMutableArray alloc]init];
    [contentArr addObject:self.survey.billnumber];
    [contentArr addObject:self.survey.state];
    [contentArr addObject:self.survey.title];
    [contentArr addObject:self.survey.productname];
    [contentArr addObject:[IBTCommon stringFromDate:self.survey.begindate]];
    [contentArr addObject:[IBTCommon stringFromDate:self.survey.enddate]];
    [contentArr addObject:self.survey.productcode];
陈俊俊's avatar
陈俊俊 committed
72
    [contentArr addObject:self.survey.remark];
n22's avatar
n22 committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    
    for (NSInteger i = 0 ; i < leftArr.count; i++) {
        UILabel *leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin, CGRectGetMaxY(tagLabel.frame) + LeftHeight *i, LeftWidth, LeftHeight)];
        leftLabel.text = leftArr[i];
        leftLabel.font = FontSize(17);
        [_surveyView addSubview:leftLabel];
        
        UILabel *rightLabel = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(leftLabel.frame), CGRectGetMaxY(tagLabel.frame) + LeftHeight *i, _surveyView.frame.size.width - LeftMargin - LeftWidth, LeftHeight)];
        rightLabel.text = contentArr[i];
        rightLabel.font = FontSize(17);
        if (i == leftArr.count - 1) {
            rightLabel.numberOfLines = 0;
            self.noteLabel = rightLabel;
        }
        [_surveyView addSubview:rightLabel];
    }
    
    _bottomView= [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(_surveyView.frame), ScreenSize.width, 200)];
    _bottomView.backgroundColor = [UIColor whiteColor];
    [_scrollView addSubview:_bottomView];
    
    UILabel *resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(LeftMargin/2, 10, LeftWidth*2, LeftHeight)];
    resultLabel.text = @"【行情反馈】";
    resultLabel.font =  FontSize(17);
    resultLabel.textColor = [UIColor blueColor];
    [_bottomView addSubview:resultLabel];
    
    UIButton *btn = [IBTCustomButtom creatButtonWithFrame:CGRectMake(CGRectGetWidth(_bottomView.frame) - 100, 10, 100, LeftHeight) target:self sel:@selector(btnClick:) tag:DetailTag image:nil title:@">>查看详情" titleColor:[UIColor blueColor] isCorner:NO corner:0 bgColor:nil];
    [_bottomView addSubview:btn];
    
    [self setNoteHeight];
}

- (void)btnClick:(UIButton *)btn{
    if (btn.tag == DetailTag) {
        ResultDetailViewController *rvc = [ResultDetailViewController new];
        
    
        [self PushViewController:rvc animated:YES];
        
    }else if (btn.tag == EndTag){
        
    }
}

- (void)setNoteHeight
{
    CGFloat height =  [self.noteLabel calculateHeight];
    
    CGRect noteFrame = self.noteLabel.frame;
    noteFrame.size.height = height;
    self.noteLabel.frame = noteFrame;
    
    CGFloat totalHeight = height + LeftHeight*9;
    CGRect surveyFrame = _surveyView.frame;
    surveyFrame.size.height = totalHeight;
    _surveyView.frame = surveyFrame;
    
    
    CGRect bottomFrame = _bottomView.frame;
    bottomFrame.origin.y = CGRectGetMaxY(_surveyView.frame);
    _bottomView.frame = bottomFrame;
    
    _scrollView.contentSize = CGSizeMake(ScreenSize.width, totalHeight + CGRectGetHeight(_bottomView.frame));
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
@end