// // LookOnLineDetailViewController.m // redstar // // Created by admin on 15/11/28. // Copyright © 2015年 ZWF. All rights reserved. // #import "LookOnLineDetailViewController.h" #import "LookOnLineDetailView.h" #define kLookOnLineDetailCell @"LookOnLineDetailCell" @interface LookOnLineDetailViewController () <UITableViewDelegate, UITableViewDataSource> @property (nonatomic, strong) UITableView *tableView; @property (nonatomic, strong) LookOnLineDetailView *headerView; @end @implementation LookOnLineDetailViewController - (void)viewDidLoad { [super viewDidLoad]; [self setNav]; self.tableView.delegate = self; self.tableView.dataSource = self; } #pragma mark - Private Mothods - (void)setNav { if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { self.edgesForExtendedLayout = UIRectEdgeNone; self.extendedLayoutIncludesOpaqueBars = NO; self.modalPresentationCapturesStatusBarAppearance = NO; self.navigationController.navigationBar.translucent = NO; } UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; backBtn.frame = CGRectMake(0, 0, 30, 44); [backBtn setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal]; [backBtn addTarget:self action:@selector(doBack:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn]; self.navigationItem.leftBarButtonItem = backItem; UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 30)]; [customLab setTextColor:[UIColor whiteColor]]; [customLab setText:@"任务处理"]; customLab.font = [UIFont boldSystemFontOfSize:19]; self.navigationItem.titleView = customLab; } - (void)doBack:(id)sender { [self.navigationController popViewControllerAnimated:YES]; } #pragma mark - UITableView Delegate/DataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 10; } // cell显示的内容 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kLookOnLineDetailCell]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kLookOnLineDetailCell]; } return cell; } #pragma mark - lazy loading - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; _tableView.translatesAutoresizingMaskIntoConstraints = NO; _tableView.showsVerticalScrollIndicator = NO; _tableView.showsHorizontalScrollIndicator = NO; _tableView.tableHeaderView = self.headerView; [self.view addSubview:_tableView]; NSLayoutConstraint *tableTop = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]; [self.view addConstraint:tableTop]; NSLayoutConstraint *tableLeft = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; [self.view addConstraint:tableLeft]; NSLayoutConstraint *tableRight = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; [self.view addConstraint:tableRight]; NSLayoutConstraint *tableBottom = [NSLayoutConstraint constraintWithItem:_tableView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]; [self.view addConstraint:tableBottom]; } return _tableView; } - (LookOnLineDetailView *)headerView { if (!_headerView) { _headerView = [[LookOnLineDetailView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 255)]; _headerView.titleLabel.text = @"2015年十一促销临时抽查"; } return _headerView; } @end