//
|
// HDLFVBaseViewController.m
|
// Ezviz
|
//
|
// Created by 陈启扬 on 2022/2/21.
|
// Copyright © 2022 hdl. All rights reserved.
|
//
|
|
#import "HDLEZBaseViewController.h"
|
#import "HDLEZNoDataView.h"
|
@interface HDLEZBaseViewController ()
|
@property (nonatomic, strong) HDLEZNoDataView *noDataV;
|
|
@end
|
|
@implementation HDLEZBaseViewController
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
//添加点击屏幕手势
|
UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc] initWithTarget: self action: @selector (viewTapped)];
|
tapGr.cancelsTouchesInView = NO ;
|
[ self.view addGestureRecognizer:tapGr];
|
|
self.view.backgroundColor=HDLEZ_COLOR_VIEW_BACKGROUND;
|
|
[self addSubViews];
|
// Do any additional setup after loading the view.
|
}
|
|
//设置标题和返回按钮
|
- (void)setTopBarViewWithTitle:(NSString *)title{
|
[self.view addSubview:self.topBarView];
|
self.topBarView.titleLabel.text = title;
|
}
|
|
-(void)addSubViews{
|
//无数据View
|
_noDataV=[[HDLEZNoDataView alloc] init];
|
[self.view addSubview:_noDataV];
|
[_noDataV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.centerY.equalTo(self.view.mas_centerY);
|
make.left.equalTo(self.view).offset(20);
|
make.right.equalTo(self.view).offset(-20);
|
make.height.mas_equalTo(60);
|
}];
|
[_noDataV setHidden:YES];
|
|
}
|
|
|
/*展示无数据提示View
|
*/
|
-(void)showNoDataViewWithMessage:(NSString *)message {
|
[_noDataV setHidden:NO];
|
_noDataV.tipMsg=message;
|
}
|
|
|
/*隐藏无数据提示View
|
*/
|
-(void)hideNoDataView{
|
[_noDataV setHidden:YES];
|
}
|
|
//退出编辑
|
-(void)viewTapped{
|
//键盘退出
|
[self.view endEditing:YES];
|
}
|
|
|
- (HDLEZTopBarView *)topBarView{
|
if (!_topBarView) {
|
_topBarView = [[HDLEZTopBarView alloc] initWithFrame: CGRectMake(0, 0, HDLEZ_APP_SCREEN_WIDTH, 40)];
|
[_topBarView.leftButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
|
[_topBarView.backButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
|
}
|
return _topBarView;
|
}
|
|
|
/*返回
|
*/
|
- (void)goBack{
|
// [self.navigationController popViewControllerAnimated:YES];
|
if ([self.navigationController.viewControllers indexOfObject:self] == 0) {
|
HDLEZLog(@"返回");
|
[self dismissViewControllerAnimated:YES completion:nil];
|
}
|
else {
|
[self.navigationController popViewControllerAnimated:YES];
|
// [self.navigationController popToRootViewControllerAnimated:YES];
|
}
|
}
|
|
//设置右边按钮标题
|
-(void)setRightBtnTitle:(NSString *)rightBtnTitle{
|
_rightBtnTitle=rightBtnTitle;
|
_topBarView.rightBtnTitle=rightBtnTitle;
|
[_topBarView.rightButton addTarget:self action:@selector(clickRightBtn) forControlEvents:UIControlEventTouchDown];
|
}
|
|
//点击右边按钮
|
-(void)clickRightBtn{
|
|
}
|
|
@end
|