| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- //
- // HJMessageViewController.m
- // HappyJob
- //
- // Created by Bob on 2019/3/13.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJMessageViewController.h"
- #import "HJMessageTableViewCell.h"
- #import "HJMessageDateTableViewCell.h"
- #import "UIViewController+HJNavBarRightButtonItems.h"
- #import "HJMessageDelPanelViewController.h"
- #import "HJMessageBlankView.h"
- @interface HJMessageViewController () <UITableViewDelegate, UITableViewDataSource>
- @property (nonatomic, strong) HJMessageBlankView *blankView;
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) UIButton *delButton;
- @end
- @implementation HJMessageViewController
- #pragma mark - life cycle
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self hj_setupNavBarRightButtonItems:@[self.delButton]];
-
- [self.view addSubview:self.blankView];
- //[self.view addSubview:self.tableView];
-
- [self makeConstraints];
- }
- - (void)makeConstraints {
- [self.blankView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self.view);
- }];
- // [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.edges.equalTo(self.view);
- // }];
- }
- #pragma mark - UITableViewDelegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 40;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.row == 0 || indexPath.row == 5) {
- static NSString *cellIdentifier = @"HJMessageDateTableViewCell";
- HJMessageDateTableViewCell *cell = (HJMessageDateTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
- if (cell == nil) {
- cell = [[HJMessageDateTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- }
- cell.dateText = @"4月2日 早上10:00";
- return cell;
- } else {
- static NSString *cellIdentifier = @"HJMessageTableViewCell";
- HJMessageTableViewCell *cell = (HJMessageTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
-
- if (cell == nil) {
- cell = [[HJMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
- }
- return cell;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- }
- #pragma mark - CustomDelegate
- #pragma mark - event response
- - (void)delButtonClicked:(UIButton *)sender {
- HJMessageDelPanelViewController *vc = [[HJMessageDelPanelViewController alloc] init];
- vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
- [self presentViewController:vc animated:YES completion:^{
-
- }];
- }
- #pragma mark - private methods
- #pragma mark - getters and setters
- - (UITableView *)tableView {
- if (_tableView == nil) {
- _tableView = [[UITableView alloc] init];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- // 设置预估行高
- _tableView.estimatedRowHeight = 40;
- // 设置行高自动计算
- _tableView.rowHeight = UITableViewAutomaticDimension;
- _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- }
- return _tableView;
- }
- - (UIButton *)delButton {
- if (_delButton == nil) {
- _delButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_delButton setImage:[UIImage imageNamed:@"navbar_del"] forState:UIControlStateNormal];
- [_delButton addTarget:self action:@selector(delButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _delButton;
- }
- - (HJMessageBlankView *)blankView {
- if (_blankView == nil) {
- _blankView = [[HJMessageBlankView alloc] init];
- }
- return _blankView;
- }
- @end
|