关闭

iOS 设置整理

标签: iOS
313人阅读 评论(0) 收藏 举报
分类:

1  图片缓存计算:(用的sdwebimage)

      -(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
   //可以用self   //这个不想写可以
    __weak typeof(self) weakSelf = self;
    
    dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
        NSString *cache = [NSString stringWithFormat:@"%@",@([[SDImageCache sharedImageCache]
                                                              getSize])];
        dispatch_async(dispatch_get_main_queue(), ^{
            
            [weakSelf calculateCacheSuccess:cache];
        });
    });
    
}

//计算缓存完成
-(void)calculateCacheSuccess:(NSString *)cache
{
    
    _cacheSizeStr = [NSString stringWithFormat:@"%@",cache];
    [_mainTableView reloadData];
}

 if (![_cacheSizeStr isEqualToString:@"0"])
        {
            cell.detailTextLabel.text = [NSString stringWithFormat:@"%.1f M",
                                         _cacheSizeStr.floatValue/1024.0/1024.0] ;
        }
        else
        {
            cell.detailTextLabel.text = @"0.0 M";
        }

2 清除缓存

    - (void)clearCache
{
    [self showLoadingView:@"清除缓存中..."];
    
    __weak typeof (self) weakSelf = self;
    
    [[SDImageCache sharedImageCache] clearDisk];

[[SDImageCache sharedImageCache] clearMemory];
    [[SDImageCache sharedImageCache] calculateSizeWithCompletionBlock:^(NSUInteger fileCount, unsigned long long totalSize) {
       
        NSString *cache = [NSString stringWithFormat:@"%@",@([[SDImageCache sharedImageCache]
                                                              getSize])];
        [weakSelf hiddenLoadingView];
        [weakSelf calculateCacheSuccess:cache];
        
    }];
}



3 :评分


//给我们评分吧
- (void)giveMark
{
    NSString * appstoreUrlString = @"https://***********";
    
    NSURL * url = [NSURL URLWithString:appstoreUrlString];
    
    if ([[UIApplication sharedApplication] canOpenURL:url])
    {
        [[UIApplication sharedApplication] openURL:url];
    }
    else
    {
        NSLog(@"can not open");
    }
}


4 检查更新

          [[UIApplication sharedApplication] openURL:[ NSURL URLWithString:Url]];

5  消息推送设置

   [pushSwitch addTarget:self
                           action:@selector(MethodStatus:)
                 forControlEvents:UIControlEventValueChanged];

-(void)MethodStatus:(UISwitch *)Switch
{

    if (pushSwitch.on) {
        
        if (MODEL_VERSION >=8.0) {
            
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
                                                                                                 |UIRemoteNotificationTypeSound
                                                                                                 |UIRemoteNotificationTypeAlert) categories:nil];
            [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
            
        }else{
            
            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound];
        }
        
    }else{
        
        [[UIApplication sharedApplication] unregisterForRemoteNotifications];
    }
    
}



  

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:50165次
    • 积分:1416
    • 等级:
    • 排名:千里之外
    • 原创:94篇
    • 转载:4篇
    • 译文:0篇
    • 评论:3条
    最新评论