| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- //
- // Person_VC.m
- // Haishenghai-master
- //
- // Created by GG on 2018/12/30.
- // Copyright © 2018年 Haishenghai intelligence network technology. All rights reserved.
- //
- #import "Person_VC.h"
- @interface Person_VC ()<UITableViewDelegate,UITableViewDataSource>
- @end
- @implementation Person_VC
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- self.view.backgroundColor = [UIColor whiteColor];
- self.navigationItem.title =@"我的";
- [self setupUI];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
-
- //设置导航栏背景图片空image透明
- [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
- //掉透明导航栏边黑边
- [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
-
-
- }
- // 如果不想让其他页面的导航栏变为透明 需要重置
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
- [self.navigationController.navigationBar setShadowImage:nil];
-
-
- }
- -(void)setupUI{
- [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor whiteColor]}];
-
- UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
- rightButton.frame = CGRectMake(0, 12, 20, 20);
- [rightButton setBackgroundImage:[UIImage imageNamed:@"hsh_home_set"] forState:UIControlStateNormal];
- [rightButton addTarget:self action:@selector(addBtnClick) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
- self.navigationItem.rightBarButtonItem = rightItem;
-
- _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, HEIGHT/4+308) style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.userInteractionEnabled = YES;
- //表禁止滑动
- _tableView.scrollEnabled =NO;
- [self.view addSubview:_tableView];
- //设置表头
- _topImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"hsh_user_background"]];
- _topImageView.frame = CGRectMake(0, 0, self.view.frame.size.width, HEIGHT/4);
- _topImageView.contentMode = UIViewContentModeScaleToFill;
- _tableView.tableHeaderView = _topImageView;
- self.tableView.showsVerticalScrollIndicator = NO;
- _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
-
- _detailImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"user"]];
- _detailImageView.layer.cornerRadius = 30;
- _detailImageView.backgroundColor = [UIColor whiteColor];
- //联系人信息
- _detailImageView.frame = CGRectMake(40, _topImageView.frame.size.height/2-20, 60, 60);
- [_topImageView addSubview:_detailImageView];
- UILabel *titleLabel =[[UILabel alloc]init];
- titleLabel.frame = CGRectMake(110, _topImageView.frame.size.height/2-20, 200, 30);
- NSString *username =[[NSUserDefaults standardUserDefaults]objectForKey:@"username"];
- titleLabel.text = username;
- titleLabel.textColor = [UIColor whiteColor];
- titleLabel.font = [UIFont systemFontOfSize:18];
- [_topImageView addSubview:titleLabel];
- UILabel *phoneLabel =[[UILabel alloc]init];
- phoneLabel.frame = CGRectMake(110, _topImageView.frame.size.height/2+10, 200, 30);
- NSString *phone =[[NSUserDefaults standardUserDefaults]objectForKey:@"phone"];
- phoneLabel.text = phone;
- phoneLabel.textColor = [UIColor whiteColor];
- phoneLabel.font = [UIFont systemFontOfSize:18];
- [_topImageView addSubview:phoneLabel];
-
- if (@available (iOS 11.0,*)) {
- self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- }else{
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- }
- #pragma mark-- tableviewDelegate
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return 4;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- if (indexPath.section==0) {
- return 44;
- }
- return 0;
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *cellId = @"cell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (!cell) {
- cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellId];
- }
- cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
- cell.preservesSuperviewLayoutMargins = false;
- cell.separatorInset = UIEdgeInsetsZero;
- cell.layoutMargins = UIEdgeInsetsZero;
- NSArray *images = @[@"hsh_user_place",/*@"hsh_user_equipment"*/@"hsh_user_alert",@"hsh_user_problem",@"hsh_user_tel"];
- NSArray *titles = @[@"场所管理",/*@"设备管理",*/@"火警通知",@"常见问题",@"联系我们"];
- cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];
- cell.textLabel.text = titles[indexPath.row];
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];//反选
- switch (indexPath.row) {
- case 0:
- {
- PlaceList_VC *placeVC = [[PlaceList_VC alloc]init];
- placeVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:placeVC animated:YES];
- } break;
- /* case 1:
- {
-
- ManageDeveceList_VC *listVC = [[ManageDeveceList_VC alloc]init];
- listVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:listVC animated:YES];
- } break;*/
- case 1:
- {
- FireAlarm_VC *fireVC = [[FireAlarm_VC alloc]init];
- fireVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:fireVC animated:YES];
- } break;
- case 2:
- {
- ProblemViewController *proVC = [[ProblemViewController alloc]init];
- proVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:proVC animated:YES];
- } break;
- case 3:
- {
- Service_VC *serviceVC = [[Service_VC alloc]init];
- serviceVC.hidesBottomBarWhenPushed = YES;
- serviceVC.navigationItem.title = @"客服电话";
- [self.navigationController pushViewController:serviceVC animated:YES];
- } break;
- default:
- break;
- }
-
- }
- #pragma mark---respose Event
- -(void)addBtnClick{
- Setting_VC *setVC = [[Setting_VC alloc]init];
- setVC.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:setVC animated:YES];
- }
- /*
- -(void)quitLoginBtnClick:(UIButton *)quitBtn{
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"你确定要退出当前账户吗?" preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
- [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- NSString *userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userid"];
- [DataSourceManager setLoginoutWithUrlwithuser:userId completionBlock:^(NSDictionary *dic) {
- //退出
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[UserLogin_VC alloc] init]];
- [UIApplication sharedApplication].keyWindow.rootViewController = nav;
- }];
- }]];
- [self presentViewController:alert animated:YES completion:nil];
-
-
-
-
- NSLog(@"点了");
-
- }*/
- - (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
|