缓存问题

//

//  MyZoneViewController.m

//  Patient

//

//  Created by MYMAc on 15/9/9.

//  Copyright (c) 2015 ShangYu. All rights reserved.

//

 

#import "SetandHelpController.h"

#import "VersionsViewController.h"

#import "RevampViewController.h"//gzz0921 修改密码

#import "FeedbackViewController.h"//gzz0921意见反馈

#import "LoginViewController.h"//gzz0921 登录

#import "HopeltViewController.h"//gzz0921 帮助

#import "AboutGandanController.h"//gzz0921 关于肝胆相照

@interface SetandHelpController ()<UITableViewDataSource,UITableViewDelegate>{

    

//    CGFloat fileSizeM;

    UITableView * _TVSatand;

    NSMutableArray * TvDataArray;

    NSString *xiaoxi;

    UILabel *labcun;

    NSString *clearCacheSTR;

//    NSString *isClear;

}

@property(nonatomic,copy)NSString *isClear;

@end

 

@implementation SetandHelpController

 

 

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor  = [UIColor whiteColor];;

    

    if ([[UIDevice currentDevice].systemVersion floatValue]>=8.0f) {

        UIUserNotificationSettings *setting = [[UIApplication sharedApplication] currentUserNotificationSettings];

        if (UIUserNotificationTypeNone == setting.types) {

            MCLog(@"推送关闭8");

            xiaoxi=@"已关闭";

        }else{

            MCLog(@"推送打开8");

            xiaoxi=@"已打开";

        }

    }else{

        UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

        if(UIRemoteNotificationTypeNone == type){

            xiaoxi=@"已关闭";

        }else{

            xiaoxi=@"已打开";

        }

    }

    NSUserDefaults *isClearDef = [NSUserDefaults  standardUserDefaults];

    [isClearDef setObject:@"11" forKey:@"isClearDEF"];

    

//    _isClear = @"1";

    [self  sethelpNavbar];

    [self makeTV];

    

   

}

 

-(void)sethelpNavbar{

    

    self.title=@"设置与帮助";

 

    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"gdback3"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];

    

    self.navigationItem.leftBarButtonItem=backItem;

    self.navigationController.interactivePopGestureRecognizer.delegate = nil;

    UIImageView *imageBim = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"jianbian5"]];

    imageBim.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

    [self.view addSubview:imageBim];

}

 

-(void)makeTV

{

 

    TvDataArray =[[NSMutableArray alloc]initWithArray:@[@"消息推送",@"",@"修改密码",@"版本",@"关于肝胆相照",@"清除缓存",@"意见反馈",@"帮助",@"拨打客服电话",@"",@""]];

    _TVSatand =[[UITableView alloc]initWithFrame:CGRectMake(0, 64,self.view.bounds.size.width, self.view.bounds.size.height-64) style:UITableViewStylePlain];

    _TVSatand.dataSource= self;

    _TVSatand.delegate = self;

    _TVSatand.backgroundColor = [UIColor clearColor];

    _TVSatand.tableFooterView =[[UIView alloc]init];

    _TVSatand.separatorStyle = UITableViewCellSeparatorStyleNone;

    //gzz0408 判断是不是5以上的屏幕,是的话不让滑动

    if (SCREEN_HEIGHT>=568) {

        _TVSatand.scrollEnabled=NO;//gzz0411 4s 也可以放的下  gzz0615 有添加了一个 关于肝胆相照 gzz0711拨打客服电话

    }else{

        _TVSatand.scrollEnabled = YES;//4s可以gzz0712 可以滚动

    }

    [self.view addSubview:_TVSatand];

    

    

}

 

#pragma mark tabeldelegate

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    

//    return TvDataArray.count;

    return 11;

 

    

}

 

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.row==1) {

        return 60;

    }else if (indexPath.row==9) {

        return 10;

    }

    else{

        return  45;

    }

}

 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    

//    UITableViewCell *cellhelp =[tableView dequeueReusableCellWithIdentifier:@"cellsethelpp"];

//    if (cellhelp == nil) {

//        cellhelp =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellsethelpp"];

//    }

    

    UITableViewCell *cellhelp=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];

 

    

//    for (UIView *view in cellhelp.contentView.subviews) {

//        [view removeFromSuperview];

//    }

    MCLog(@"indexpath.row  %zd", indexPath.row);

    cellhelp.selectionStyle = UITableViewCellSelectionStyleNone;

    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    if (indexPath.row==0) {

        cellhelp.textLabel.font =[UIFont systemFontOfSize:16];

        

        cellhelp.textLabel.text = TvDataArray[indexPath.row];

        

        UILabel *closeOpen=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-80, 12.5, 65, 20)];

        closeOpen.text= xiaoxi;

        closeOpen.textAlignment=NSTextAlignmentRight;

        

        

        [cellhelp.contentView addSubview:closeOpen];

        

        

    }else

        

    if(indexPath.row == 1){

            cellhelp.backgroundColor=RGB(232, 231,231);

            UILabel *show=[[UILabel alloc]initWithFrame:CGRectMake(15, 15, SCREEN_WIDTH-30, 20)];

            show.font=SYSTEMFONT(14);

            

            

            NSMutableAttributedString *strnn = [[NSMutableAttributedString alloc] initWithString:@"要开启或关闭,您可以通过iPhone的设置-通知-肝胆相照 允许通知 手动设置"];

            

            //  [strnn addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(30,4)]; //设置字体颜色

            //[UIFont boldSystemFontOfSize:20];  [UIFont fontWithName:@"Arial" size:20.0]

            [strnn addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:NSMakeRange(30, 4)]; //设置字体字号和字体类别

         

            //要开启或关闭,您可以通过iPhone的设-通知-肝胆相照 允许通知(加粗手动设置

            show.attributedText=strnn;

            show.numberOfLines=0;

            show.lineBreakMode=NSLineBreakByWordWrapping;

            [show sizeToFit];

            [cellhelp.contentView addSubview:show];

            

        }

    else if(indexPath.row == 3){

            

            cellhelp.textLabel.font =[UIFont systemFontOfSize:16];

            

            cellhelp.textLabel.text = TvDataArray[indexPath.row];

            

            UILabel *closeOpen=[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-100, 12.5, 65+20, 20)];

            closeOpen.text=@"V1.5.1";//gzz1031

            closeOpen.textAlignment=NSTextAlignmentRight;

            

            

            [cellhelp.contentView addSubview:closeOpen];

            

        }

    else if(indexPath.row == 10){

                

                

                UILabel *indelab= [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 45)];

                indelab.textAlignment = YES;

                indelab.text = @"退出登录";

                indelab.textColor = RGB(60, 192, 188);

                [cellhelp.contentView addSubview:indelab];

                cellhelp.separatorInset = UIEdgeInsetsMake(0, cellhelp.bounds.size.width, 0, 0);

                

                

            }

    else if(indexPath.row == 9) {

                

                cellhelp.backgroundColor=RGB(232, 231,231);;

                

                cellhelp.separatorInset = UIEdgeInsetsMake(0, SCREEN_WIDTH, 0, 0);

            }

    else if(indexPath.row == 5)  {

 

                cellhelp.textLabel.text =[NSString stringWithFormat:@"%@", TvDataArray[indexPath.row]];

                cellhelp.textLabel.font=[UIFont systemFontOfSize:16];

 

        

                labcun  = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-150,0, 135,45)];

        NSUserDefaults *isClearDef = [NSUserDefaults  standardUserDefaults];

        NSString *isclearDef = [NSString stringWithFormat:@"%@",[isClearDef objectForKey:@"isClearDEF"]];

        if ([isclearDef isEqualToString:@"11"]) {

            [[SDImageCache sharedImageCache] clearDisk];//gzz1102

            _isClear = @"0";

            float tmpSize = [[SDImageCache sharedImageCache] checkTmpSize];

            

            

            NSString *clearCache = tmpSize >= 1 ? [NSString stringWithFormat:@"%.2fM",tmpSize] : [NSString stringWithFormat:@"%.2fK",tmpSize * 1024];

            

            NSUserDefaults *ClearDefNum = [NSUserDefaults  standardUserDefaults];

            NSString *nums = [NSString stringWithFormat:@"%@",clearCache];

            [ClearDefNum setObject:nums forKey:@"ClearDefNum"];

            

//            clearCacheSTR = clearCache;

            MCLog(@"缓存大小...%@",clearCache);

        }

        

//        if ([_isClear isEqualToString:@"1"]) {

//            [[SDImageCache sharedImageCache] clearDisk];//gzz1102

//            _isClear = @"0";

//            float tmpSize = [[SDImageCache sharedImageCache] checkTmpSize];

//            

//            

//            NSString *clearCache = tmpSize >= 1 ? [NSString stringWithFormat:@"%.2fM",tmpSize] : [NSString stringWithFormat:@"%.2fK",tmpSize * 1024];

//            

//            clearCacheSTR = clearCache;

//             MCLog(@"缓存大小...%@",clearCache);

//        }

        labcun.font=[UIFont systemFontOfSize:14];

        

        NSUserDefaults *ClearDefNum = [NSUserDefaults  standardUserDefaults];

       NSString *nums = [ClearDefNum  objectForKey:@"ClearDefNum"];

        labcun.text = nums;

       

        labcun.textColor = RGB(188, 188, 188);

        labcun.textAlignment = NSTextAlignmentRight;

 

        

        [cellhelp.contentView addSubview:labcun];

        

            }

    else if (indexPath.row == 8){

                cellhelp.textLabel.font =[UIFont systemFontOfSize:16];

                

                cellhelp.textLabel.text =[NSString stringWithFormat:@"%@", TvDataArray[indexPath.row]];

                

                UIView *bgggview = [[UIView alloc]init];

                [cellhelp.contentView addSubview:bgggview];

                bgggview.backgroundColor = [UIColor clearColor];

                //          bgggview.frame = CGRectMake(SCREEN_HEIGHT-200, 0, 200-15, 45);

                //

//                UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(phoneCall:)];

//                [bgggview addGestureRecognizer:gesture];

        

                

                UILabel  *phonum = [[UILabel alloc]init];

                phonum.text = @"400-175-6866";

                phonum.textColor = RGB(60, 199, 192);

                phonum.font = SYSTEMFONT(14);

                [phonum sizeToFit];

                phonum.frame = CGRectMake( SCREEN_WIDTH-phonum.width-15, (45-phonum.height)/2, phonum.width, phonum.height);

                [cellhelp.contentView addSubview:phonum];

                

                UIImageView *phoneImage = [[UIImageView  alloc]init];

                phoneImage.image = [UIImage imageNamed:@"iphonecall34"];

                phoneImage.frame = CGRectMake(phonum.x-5-16, 10, 16, 16);

                phoneImage.centerY = phonum.centerY;

                [cellhelp.contentView addSubview:phoneImage];

                

                bgggview.frame = CGRectMake(phoneImage.x, 0, phoneImage.width+phonum.width+15, 45);

                

            }

    else

    {

        cellhelp.textLabel.font =[UIFont systemFontOfSize:16];

        cellhelp.textLabel.text = TvDataArray[indexPath.row];

        UIImageView *imageviewH = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-25, 17, 7, 11)];

        imageviewH.image = [UIImage imageNamed:@"返回键-拷贝-23"];

    

        [cellhelp.contentView addSubview:imageviewH];

        

                

    }

    

    

    

    

    if(indexPath.row==10||indexPath.row==0||indexPath.row==1||indexPath.row==8||indexPath.row==9){

        

    }

    else

    {

        

        UILabel *labcuna  = [[UILabel alloc]initWithFrame:CGRectMake(15,44.5,SCREEN_WIDTH-15,0.5)];

        labcuna.backgroundColor = RGB(180, 180,180);

        [cellhelp.contentView addSubview:labcuna];

    }

    

    cellhelp.contentView.backgroundColor = [UIColor clearColor];

    

    return cellhelp;

    

    

}

 

#pragma mark 拨打电话

-(void)phoneCall:(UITapGestureRecognizer *)ges{

 

    UIAlertView *alcer = [[UIAlertView alloc]initWithTitle:@"确定拨打" message:@"客服电话 4001756866\n工作时间 8:30 21:00 " delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

    alcer.tag = 1095;

    [alcer show];

  

}

 

-(void)phoneCalling{

    

    UIAlertView *alcer = [[UIAlertView alloc]initWithTitle:@"确定拨打" message:@"客服电话 4001756866\n工作时间 8:30 21:00 " delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

    alcer.tag = 1095;

    [alcer show];

    

}

 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    

    if (indexPath.row==0) {

        

    } else

    if (indexPath.row==1) {

        

    }else

    

    if (indexPath.row==2) {

        RevampViewController *resa = [[RevampViewController alloc]init];

        resa.hidesBottomBarWhenPushed=YES;//gzz0329dev

        [self.navigationController pushViewController:resa animated:YES];

    }else

    if (indexPath.row == 8) {

 

        [self phoneCalling];//gzz1009

    }

    else

    if (indexPath.row==4) {

        AboutGandanController *ver = [[AboutGandanController alloc]init];

        ver.hidesBottomBarWhenPushed=YES;//gzz0329dev

        [self.navigationController pushViewController:ver animated:YES];

    }else

    

    if(indexPath.row == 5){

        [self clearCashSelf];

    }

    else

    if (indexPath.row==6) {

        FeedbackViewController *feed  = [[FeedbackViewController alloc]init];

        feed.hidesBottomBarWhenPushed=YES;//gzz0329dev

        [self.navigationController pushViewController:feed animated:YES];

    }else

    if (indexPath.row==7) {

        HopeltViewController *hot = [[HopeltViewController alloc]init];

        hot.hidesBottomBarWhenPushed=YES;//gzz0329dev

        [self.navigationController pushViewController:hot animated:YES];

    }

    

    else

    if (indexPath.row==10) {

        UIAlertView *alve = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"真的要退出吗?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

        [alve show];

    }

    else{

    

    

    }

    

    

}

 

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    

    if (alertView.tag == 8899) {

        

        if (buttonIndex == 0) {

            

            

        }else{

            

            [self clearTmpPics];

        }

    }

    else   if (alertView.tag==1095) {

        if (buttonIndex==1) {

            

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://4001756866"]];

            

        }else{

            MCLog(@"取消键");

            

        }

    }

    else {

        

        if (buttonIndex==1) {

            

            MBProgressHUD *hub = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

            hub.removeFromSuperViewOnHide = YES;

            hub.labelText = @"正在退出";

            //gzz0512 登录登出 退出当前账号

            [[ECDevice sharedInstance] logout:^(ECError *error) {

                [MBProgressHUD hideHUDForView:self.view animated:YES];

                [DemoGlobalClass sharedInstance].userName = nil;

                

                [DemoGlobalClass sharedInstance].isLogin = NO;

                

                //            //为了页面的跳转,使用了该错误码,用户在使用过程中,可以自定义消息,或错误码值

                ////            [[NSNotificationCenter defaultCenter] postNotificationName:@"zhuxiaoDengluPENINET" object:[ECError errorWithCode:10]];

                //                            [[NSNotificationCenter defaultCenter] postNotificationName:KNOTIFICATION_onConnected object:[ECError errorWithCode:10]];

                NSUserDefaults *user = [NSUserDefaults standardUserDefaults];

                [user setObject:@"1122" forKey:@"registersucceed"];

                [user setObject:@"123" forKey:@"perfectInfo"];

                

                [user synchronize];

                Dlpontlerexple *dd=[Dlpontlerexple shareIndence];

                

                NSString  *ddd=[NSString stringWithFormat:@"%@", dd.mobileStr];

                LoginViewController *login = [[LoginViewController alloc]init];

                login.phoneStr=ddd;

                

                login.strZhuxiao = @"fanhuiLogin";

                [self.navigationController pushViewController:login animated:YES];

                [[NSNotificationCenter defaultCenter] postNotificationName:@"TUICHUzhuxiaoDenglu" object:nil];

                

            }];

 

        }

    }

    

}

 

-(void)clearCashSelf{

   

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"清除本地缓存" message:labcun.text delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

    alert.tag = 8899;

    [alert show];

    

}

 

#pragma mark sd清楚缓存

- (void)clearTmpPics

{

  

        [[SDImageCache sharedImageCache] clearDisk];

        

        float tmpSize = [[SDImageCache sharedImageCache] checkTmpSize];

        

        NSString *clearCacheName = tmpSize >= 1 ? [NSString stringWithFormat:@"清理缓存(%.2fM)",tmpSize] : [NSString stringWithFormat:@"清理缓存(%.2fK)",tmpSize * 1024];

        

        

        NSString *clearCache = tmpSize >= 1 ? [NSString stringWithFormat:@"%.2fM",tmpSize] : [NSString stringWithFormat:@"%.2fK",tmpSize * 1024];

        

        MCLog(@"%@",clearCacheName);

        

        labcun.text =clearCache;

 

        _isClear = @"1";

    

    NSUserDefaults *isClearDef = [NSUserDefaults  standardUserDefaults];

    [isClearDef setObject:@"00" forKey:@"isClearDEF"];

 

}

 

-(void)backClick{

    

    [self.navigationController popViewControllerAnimated:YES];

    

}

 

- (void)dealloc{

    //移除指定的通知,不然会造成内存泄露 //gzz0921notice

    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"TUICHUzhuxiaoDenglu" object:nil];

    

    [[NSNotificationCenter defaultCenter] removeObserver:self];

}

 

-(void)didReceiveMemoryWarning{

 

    [super didReceiveMemoryWarning];

}

 

@end

 

 

 

 

posted @ 2016-11-02 17:27  zhen_zhen  阅读(257)  评论(0编辑  收藏  举报