Commit ecb1d7e4 authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

contacts delete

parent 7ed20373
This diff is collapsed.
//
// ICContactListModel.h
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Contacts/Contacts.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactListModel : NSObject
@property(nonatomic,strong)CNContact *contact;
@property(nonatomic,assign)BOOL choose;
@end
NS_ASSUME_NONNULL_END
//
// ICContactListModel.m
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactListModel.h"
@implementation ICContactListModel
@end
//
// ICContactsBackup.h
// superCleaner
//
// Created by GY.Z on 2020/7/7.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactsBackup : NSObject
@property(nonatomic,copy)NSString *kMDItemContentType;
@property(nonatomic,copy)NSString *kMDItemFSContentChangeDate;
@property(nonatomic,copy)NSString *kMDItemFSName;
@property(nonatomic,copy)NSURL *kMDItemURL;
@property(nonatomic,copy)NSString *kMDItemFSSize;
@property(nonatomic,copy)NSString *timestamp;
@property(nonatomic,assign)BOOL choose;
@end
NS_ASSUME_NONNULL_END
//
// ICContactsBackup.m
// superCleaner
//
// Created by GY.Z on 2020/7/7.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactsBackup.h"
@implementation ICContactsBackup
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
}
@end
//
// ICContactsTool.h
// superCleaner
//
// Created by GY.Z on 2020/7/6.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <Contacts/Contacts.h>
NS_ASSUME_NONNULL_BEGIN
@protocol ICContactsToolDelegate <NSObject>
// 获取iCloud联系人
-(void)getiCloudContactsMethods:(NSData *)obj fileInfo:(NSDictionary *)fileInfo;
/// 获取iCloud列表
-(void)getiCloudList:(NSArray *)lists;
@end
@interface ICContactsTool : NSObject
@property(nonatomic,weak)id <ICContactsToolDelegate> delegate;
+(instancetype)shareInstance;
// 获取联系人
-(NSArray *)fetchContacts;
// 获取联系人授权状态
-(BOOL)contactsAuthStatus;
// 删除联系人
- (void)deleteContact:(CNMutableContact *)contact;
// 更新联系人
- (void)updateContact:(CNMutableContact *)contact;
// 获取iCloud容器联系人
-(void)getiCloudContactsPath:(NSURL *)path;
/// 获取联系人列表
-(void)loadiCloudDirectory;
/// 备份联系人
-(void)synciCloudContactsFileName:(NSString *)fileName;
/// 删除备份
-(void)deleteiCloudContactsUrlFile:(NSURL *)urlFile;
// 获取日期天
-(NSInteger)getCurrentDay;
-(NSString *)convertStrToTime:(NSString *)timeStr;
/// 获取时间戳
-(NSString *)getNowTimeTimestamp;
/// 设置删除和合并次数
-(void)registerDeleteOrMergeCount;
/// 重置删除和合并次数
-(void)resetCount;
/// 联系人详情note信息
@property(nonatomic,copy)NSString *note;
/// 进入联系人详情
-(void)enterContactsDetail:(CNContact *)contact controller:(UIViewController *)controller push:(BOOL)push;
@end
NS_ASSUME_NONNULL_END
This diff is collapsed.
//
// PYHDocument.h
// superCleaner
//
// Created by GY.Z on 2020/7/6.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol PYHDocumentDelegate <NSObject>
-(void)docGetiCloudContactsMethods:(NSData *)obj fileInfo:(NSDictionary *)fileInfo;
@end
@interface PYHDocument : UIDocument
//文档的二进制数据
@property (nonatomic, strong) NSData *saveData;
//文档存入空间的名字
@property (nonatomic, copy) NSString *saveFileName;
@property(nonatomic,weak)id <PYHDocumentDelegate> delegate;
@end
NS_ASSUME_NONNULL_END
//
// PYHDocument.m
// superCleaner
//
// Created by GY.Z on 2020/7/6.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "PYHDocument.h"
@interface PYHDocument ()
//存储空间地址
@property (nonatomic, strong) NSURL *container;
@end
@implementation PYHDocument
- (instancetype)initWithFileURL:(NSURL *)url {
if (self = [super initWithFileURL:url]) {
self.container = url;
}
return self;
}
- (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName error:(NSError * _Nullable __autoreleasing *)outError {
//提取数据 这里的数据解析和存入数据的时候配套
NSLog(@"%@-%@",contents,typeName);
//1.根据存入处理 这里得到取出数据格式 严谨一些当然是进行相关判断
NSFileWrapper *apper = (NSFileWrapper *)contents;
//2.对数据进行解析
[apper.fileWrappers enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSFileWrapper * _Nonnull obj, BOOL * _Nonnull stop) {
NSLog(@"对数据进行解析 = %@-=-=-=-=%@",obj.filename,obj.fileAttributes);
if (self.delegate && [self.delegate respondsToSelector:@selector(docGetiCloudContactsMethods:fileInfo:)]) {
[self.delegate docGetiCloudContactsMethods:obj.regularFileContents fileInfo:obj.fileAttributes];
}
}];
return YES;
}
- (id)contentsForType:(NSString *)typeName error:(NSError * _Nullable __autoreleasing *)outError {
//写入数据
NSLog(@"写入数据 = %@",typeName);
//1.获取目录
NSFileWrapper *wrapper = [[NSFileWrapper alloc] initWithURL:self.container options:NSFileWrapperReadingImmediate error:nil];
//1-1.目录获取失败 证明没有指定目录 那么创建一个
if (!wrapper) {
wrapper = [[NSFileWrapper alloc]initDirectoryWithFileWrappers:@{}];
}
//2.配置储存文档及文档名
if (self.saveData && self.saveFileName) {
//这里遇到的问题是重复文件不会覆盖,然后系统进行了文件名的处理。使目录中,存入了同样的数据。
NSFileWrapper *preWrapper = [wrapper.fileWrappers objectForKey:self.saveFileName];
if (preWrapper) {
[wrapper removeFileWrapper:preWrapper];
}
NSFileWrapper *dataWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:self.saveData];
dataWrapper.preferredFilename = self.saveFileName;
[wrapper addFileWrapper:dataWrapper];
}
return wrapper;
}
@end
//
// ICContactBackupController.h
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Contacts/Contacts.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactBackupController : UIViewController
@property (nonatomic, strong) NSMutableArray<CNContact *> *contacts;
@end
NS_ASSUME_NONNULL_END
//
// ICContactBackupController.m
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactBackupController.h"
#import "ICContactsTool.h"
#import "ICContactsBackupCell.h"
#import "ICContactsBackupHeader.h"
#import "ICContactsBackup.h"
#import "ICContactsBackupSubController.h"
static NSString * const ICContactsBackupCellID = @"ICContactsBackupCellID";
@interface ICContactBackupController ()<UITableViewDataSource, UITableViewDelegate,ICContactsToolDelegate>
@property (strong, nonatomic) UIButton *backupButton;
@property (nonatomic, strong) UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataArray;
@property(nonatomic,strong)UIButton *deleteButton;
@property(nonatomic,strong)ICContactsTool *tools;
@end
@implementation ICContactBackupController
-(NSMutableArray *)dataArray
{
if (!_dataArray) {
_dataArray = [[NSMutableArray alloc] init];
}
return _dataArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self setupUI];
}
-(void)setupUI
{
self.navigationItem.title = ICLocalized(@"BackupContact");
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:ICLocalized(@"ChooseAll") style:UIBarButtonItemStyleDone target:self action:@selector(chooseAction)];
self.tableView = [[UITableView alloc] initWithFrame: self.view.bounds style: UITableViewStylePlain];
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.rowHeight = 50;
self.tableView.tableFooterView = [[UIView alloc] init];
// [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.tableView registerNib:[UINib nibWithNibName:@"ICContactsBackupCell" bundle:nil] forCellReuseIdentifier:ICContactsBackupCellID];
self.deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.deleteButton setTitle:ICLocalized(@"BackupImmediately") forState:UIControlStateNormal];
[self.deleteButton setBackgroundImage:[UIImage imageNamed:@"global_green_btn_bg"] forState:UIControlStateNormal];
[self.deleteButton addTarget:self action:@selector(backupAction:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.deleteButton];
self.deleteButton.hidden = NO;
[self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.bottom.equalTo(@(-40));
make.height.equalTo(@62);
make.width.equalTo(@343);
}];
ICContactsBackupHeader *header = [[ICContactsBackupHeader alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 110)];
[self.tableView setTableHeaderView:header];
self.tools = [ICContactsTool shareInstance];
self.tools.delegate = self;
[self.tools loadiCloudDirectory];
}
-(void)chooseAction
{
NSString *name = self.navigationItem.rightBarButtonItem.title;
BOOL choose;
if ([name isEqualToString:ICLocalized(@"ChooseAll")]) {
self.navigationItem.rightBarButtonItem.title = ICLocalized(@"CancelAll");
choose = YES;
}else{
self.navigationItem.rightBarButtonItem.title = ICLocalized(@"ChooseAll");
choose = NO;
}
for (ICContactsBackup *model in self.dataArray) {
model.choose = choose;
}
[self queryChooseContact];
[self.tableView reloadData];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 50;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.01;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ICContactsBackupCell *cell = [tableView dequeueReusableCellWithIdentifier:ICContactsBackupCellID forIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
if (self.dataArray.count) {
ICContactsBackup *model = self.dataArray[indexPath.row];
cell.model = model;
[cell.button addTarget:self action:@selector(cellChooseAction:) forControlEvents:UIControlEventTouchUpInside];
}
return cell;
}
-(void)cellChooseAction:(UIButton *)sender
{
ICContactsBackupCell *cell = (ICContactsBackupCell *)sender.superview.superview;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
// NSLog(@"点击的是第%ld = row",indexPath.row);
ICContactsBackup *model = self.dataArray[indexPath.row];
model.choose = !model.choose;
[self queryChooseContact];
[self.tableView reloadData];
}
-(void)queryChooseContact
{
[self.deleteButton setTitle:ICLocalized(@"BackupImmediately") forState:UIControlStateNormal];
for (ICContactsBackup *model in self.dataArray) {
if (model.choose) {
[self.deleteButton setTitle:ICLocalized(@"DeleteSelected") forState:UIControlStateNormal];
break;
}
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[MobClick event:@"contact_backup_file_click"];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
ICContactsBackup *model = self.dataArray[indexPath.row];
[self.tools getiCloudContactsPath:model.kMDItemURL];
}
/// Delegate
-(void)getiCloudContactsMethods:(NSData *)obj fileInfo:(nonnull NSDictionary *)fileInfo
{
// NSLog(@"fileInfo = %@",fileInfo);
NSArray *arr = [NSKeyedUnarchiver unarchiveObjectWithData:obj];
// NSLog(@"contacts = %@",arr);
ICContactsBackupSubController *vc = [ICContactsBackupSubController new];
vc.contacts = arr;
[self.navigationController pushViewController:vc animated:YES];
}
-(void)getiCloudList:(NSArray *)lists
{
NSLog(@"lists = %@",lists);
if (lists.count == 0){
[self.deleteButton setTitle:ICLocalized(@"BackupImmediately") forState:UIControlStateNormal];
}
[self.dataArray removeAllObjects];
NSMutableArray *temp =@[].mutableCopy;
for (NSDictionary *dict in lists) {
ICContactsBackup *model = [ICContactsBackup new];
[model setValuesForKeysWithDictionary:dict];
NSString *name = dict[@"kMDItemFSName"];
if ([name containsString:@"Contacts-"]) {
NSArray *arr = [name componentsSeparatedByString:@"-"];
if (arr.count > 1) {
model.timestamp = arr[1];
}else{
model.timestamp = @"0";
}
}
[temp addObject:model];
}
/// 按时间排序
NSArray *dataArr = [temp sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
ICContactsBackup *model1 = (ICContactsBackup *)obj1;
ICContactsBackup *model2 = (ICContactsBackup *)obj2;
if ([model1.timestamp integerValue] < [model2.timestamp integerValue]) {
return NSOrderedDescending;
}else if ([model1.timestamp integerValue] > [model2.timestamp integerValue]){
return NSOrderedAscending;
}
return NSOrderedSame;
}];
[self.dataArray addObjectsFromArray:dataArr];
[self.tableView reloadData];
}
- (void)backupAction:(UIButton *)sender {
NSString *name = self.deleteButton.titleLabel.text;
if ([name isEqualToString:ICLocalized(@"BackupImmediately")]) {
[MobClick event:@"contact_backup_now"];
NSLog(@"立即备份");
ICContactsTool *tools = [ICContactsTool shareInstance];
NSString *time = [tools getNowTimeTimestamp];
[tools synciCloudContactsFileName:time];
}else{
NSLog(@"删除所选");
[MobClick event:@"contact_backup_file_delete"];
if (self.dataArray.count == 0) return;
for (ICContactsBackup *model in self.dataArray) {
if (model.choose) {
[self.tools deleteiCloudContactsUrlFile:model.kMDItemURL];
}
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.tools loadiCloudDirectory];
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
-(NSString *)getRandomStr
{
char data[6];
for (int x=0;x < 6;data[x++] = (char)('A' + (arc4random_uniform(26))));
NSString *randomStr = [[NSString alloc] initWithBytes:data length:6 encoding:NSUTF8StringEncoding];
NSString *string = [NSString stringWithFormat:@"%@",randomStr];
return string;
}
/*
#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
//
// ICContactIncompleteController.h
// superCleaner
//
// Created by Mazy on 2020/7/3.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Contacts/Contacts.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactIncompleteController : UIViewController
@property (nonatomic, strong) NSMutableArray<CNContact *> *contacts;
@end
NS_ASSUME_NONNULL_END
//
// ICContactIncompleteController.m
// superCleaner
//
// Created by Mazy on 2020/7/3.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactIncompleteController.h"
#import <ContactsUI/ContactsUI.h>
#import "ICContactsIncompleteCell.h"
#import "ICContactListModel.h"
#import "Masonry.h"
#import "ICContactsTool.h"
static NSString * const ICContactsIncompleteCellID = @"ICContactsIncompleteCellID";
@interface ICContactIncompleteController () <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataArray;
@property(nonatomic,strong)UIButton *deleteButton;
@end
@implementation ICContactIncompleteController
-(NSMutableArray *)dataArray
{
if (!_dataArray) {
_dataArray = [[NSMutableArray alloc] init];
}
return _dataArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
[self groupsSources];
}
-(void)setupUI
{
self.navigationItem.title = ICLocalized(@"AddressInComplete");
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:ICLocalized(@"ChooseAll") style:UIBarButtonItemStyleDone target:self action:@selector(chooseAction)];
self.tableView = [[UITableView alloc] initWithFrame: self.view.bounds style: UITableViewStylePlain];
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.rowHeight = 90;
self.tableView.tableFooterView = [[UIView alloc] init];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.tableView registerNib:[UINib nibWithNibName:@"ICContactsIncompleteCell" bundle:nil] forCellReuseIdentifier:ICContactsIncompleteCellID];
self.deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.deleteButton setTitle:ICLocalized(@"DeleteSelected") forState:UIControlStateNormal];
[self.deleteButton setBackgroundImage:[UIImage imageNamed:@"global_green_btn_bg"] forState:UIControlStateNormal];
[self.deleteButton addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.deleteButton];
self.deleteButton.hidden = YES;
[self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.bottom.equalTo(@(-40));
make.height.equalTo(@62);
make.width.equalTo(@343);
}];
}
-(void)groupsSources
{
[self.dataArray removeAllObjects];
for (CNContact *con in self.contacts) {
ICContactListModel *model = [ICContactListModel new];
model.contact = con;
model.choose = NO;
[self.dataArray addObject:model];
}
[self.tableView reloadData];
}
-(void)deleteAction
{
[MobClick event:@"contact_incomplete_delete_all"];
NSInteger idx = 0;
for (ICContactListModel *model in self.dataArray) {
if (model.choose) {
idx ++;
}
}
// NSString *key = [NSString stringWithFormat:@"%ld",(long)[[ICContactsTool shareInstance] getCurrentDay]];
// NSUbiquitousKeyValueStore *keyValueStore = [NSUbiquitousKeyValueStore defaultStore];
// NSString *count = [keyValueStore objectForKey:[NSString stringWithFormat:@"delete_%@",key]];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:ICLocalized(@"Cancel") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
NSString *delete = [NSString stringWithFormat:@"%@(%ld)",ICLocalized(@"Delete"),(long)idx];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:delete style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[MobClick event:@"contact_incomplete_delete_select"];
// if ([count integerValue] > 0) {
// if (idx > [count integerValue]) {
// [MBProgressHUD showMessage:[NSString stringWithFormat:@"剩余删除次数为%@",count]];
// return ;
// }else{
// NSString *value = [NSString stringWithFormat:@"%ld",(long)[count integerValue] - idx];
// [keyValueStore setObject:value forKey:[NSString stringWithFormat:@"delete_%@",key]];
// [keyValueStore synchronize];
// }
// }else{
// [MBProgressHUD showMessage:@"剩余删除次数为0"];
// return ;
// }
for (ICContactListModel *model in self.dataArray) {
if (model.choose) {
CNMutableContact *contact = (CNMutableContact *)[model.contact mutableCopy];
[[ICContactsTool shareInstance] deleteContact:contact];
}
}
[self fetchContacts];
}];
// NSString *msg = [NSString stringWithFormat:@"每日限制:5\n剩余:%@",count];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:ICLocalized(@"DeleteContact") message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alert addAction:cancelAction];
[alert addAction:sureAction];
[self presentViewController:alert animated:YES completion:nil];
}
// 查询是否有选中的联系人
-(void)queryChooseContact
{
self.deleteButton.hidden = YES;
for (ICContactListModel *model in self.dataArray) {
if (model.choose) {
self.deleteButton.hidden = NO;
break;
}
}
}
- (void)fetchContacts {
self.contacts = [NSMutableArray array];
NSArray *array = [[ICContactsTool shareInstance] fetchContacts];
for (CNContact *con in array) {
if (con.phoneNumbers.count <= 0) {
[self.contacts addObject:con];
}
}
[self groupsSources];
}
-(void)chooseAction
{
NSString *name = self.navigationItem.rightBarButtonItem.title;
if ([name isEqualToString:ICLocalized(@"ChooseAll")]) {
self.navigationItem.rightBarButtonItem.title = ICLocalized(@"CancelAll");
[self exchangeChooseState:YES];
}else{
self.navigationItem.rightBarButtonItem.title = ICLocalized(@"ChooseAll");
[self exchangeChooseState:NO];
}
[self queryChooseContact];
[self.tableView reloadData];
}
-(void)exchangeChooseState:(BOOL)state
{
for (ICContactListModel *model in self.dataArray) {
model.choose = state;
}
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0.1;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return [[UIView alloc] init];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ICContactsIncompleteCell *cell = [tableView dequeueReusableCellWithIdentifier:ICContactsIncompleteCellID forIndexPath:indexPath];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
if (self.dataArray.count) {
ICContactListModel *model = self.dataArray[indexPath.row];
cell.model = model;
[cell.chooseBtn addTarget:self action:@selector(cellChooseAction:) forControlEvents:UIControlEventTouchUpInside];
}
return cell;
}
-(void)cellChooseAction:(UIButton *)sender
{
ICContactsIncompleteCell *cell = (ICContactsIncompleteCell *)sender.superview.superview.superview;
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
// NSLog(@"点击的是第%ld = row",indexPath.row);
ICContactListModel *model = self.dataArray[indexPath.row];
model.choose = !model.choose;
[self queryChooseContact];
[self.tableView reloadData];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:true];
if (self.dataArray.count == 0) return;
ICContactListModel *model = self.dataArray[indexPath.row];
//1.创建Contact对象,必须是可变的
CNContactViewController *contactController = [CNContactViewController viewControllerForContact:model.contact];
// contactController.delegate = self;
/// 是否显示打电话、发短信等按钮
contactController.allowsActions = YES;
/// 能否修改数据
contactController.allowsEditing = YES;
/// 是否显示联系人的关联联系人
contactController.shouldShowLinkedContacts = true;
[contactController viewDidLoad];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: contactController];
UIButton *cancelBtn = [UIButton buttonWithType: UIButtonTypeSystem];
[cancelBtn setTitle:ICLocalized(@"Cancel") forState: UIControlStateNormal];
cancelBtn.titleLabel.font = [UIFont systemFontOfSize:17];
[cancelBtn addTarget:self action:@selector(dismissContactController) forControlEvents:UIControlEventTouchUpInside];
contactController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: cancelBtn];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:nav animated:YES completion:nil];
}
- (void)dismissContactController {
[self.navigationController dismissViewControllerAnimated:true completion:nil];
}
@end
//
// ICContactListViewController.h
// superCleaner
//
// Created by Mazy on 2020/7/2.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Contacts/Contacts.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactListViewController : UIViewController
@property (nonatomic, strong) NSMutableArray<CNContact *> *contacts;
@end
NS_ASSUME_NONNULL_END
//
// ICContactRepetViewController.h
// superCleaner
//
// Created by Mazy on 2020/7/3.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Contacts/Contacts.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactRepeatViewController : UIViewController
@property (nonatomic, strong) NSArray<NSArray<CNContact *> *> *dataSoruce;
@end
NS_ASSUME_NONNULL_END
//
// ICContactsBackupSubController.h
// superCleaner
//
// Created by GY.Z on 2020/7/8.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Contacts/Contacts.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactsBackupSubController : UIViewController
@property (nonatomic, strong) NSArray *contacts;
@end
NS_ASSUME_NONNULL_END
//
// ICContactsBackupSubController.m
// superCleaner
//
// Created by GY.Z on 2020/7/8.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactsBackupSubController.h"
#import <ContactsUI/ContactsUI.h>
#import "BMChineseSort.h"
#import "ICContactsListCell.h"
#import "ICContactListModel.h"
static NSString * const ICContactsListSubCellID = @"ICContactsListSubCellID";
@interface ICContactsBackupSubController ()<UITableViewDataSource, UITableViewDelegate, CNContactViewControllerDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataArray;
@end
@implementation ICContactsBackupSubController
-(NSMutableArray *)dataArray
{
if (!_dataArray) {
_dataArray = [[NSMutableArray alloc] init];
}
return _dataArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"备份";
self.tableView = [[UITableView alloc] initWithFrame: self.view.bounds style: UITableViewStylePlain];
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.rowHeight = 50;
self.tableView.tableFooterView = [[UIView alloc] init];
[self.tableView registerNib:[UINib nibWithNibName:@"ICContactsListCell" bundle:nil] forCellReuseIdentifier:ICContactsListSubCellID];
for (CNContact *contact in self.contacts) {
ICContactListModel *model = [ICContactListModel new];
model.contact = contact;
[self.dataArray addObject:model];
}
NSLog(@"%@",self.contacts);
[self.tableView reloadData];
}
//section行数
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
//每组section个数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.dataArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0.01;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 0.01;
}
//返回cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
ICContactsListCell *cell = [tableView dequeueReusableCellWithIdentifier:ICContactsListSubCellID];
if (self.contacts.count) {
ICContactListModel *model = self.dataArray[indexPath.row];
cell.model = model;
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:true];
ICContactListModel *model = self.dataArray[indexPath.row];
//1.创建Contact对象,必须是可变的
CNContactViewController *contactController = [CNContactViewController viewControllerForContact:model.contact];
contactController.delegate = self;
/// 是否显示打电话、发短信等按钮
contactController.allowsActions = YES;
/// 能否修改数据
contactController.allowsEditing = YES;
/// 是否显示联系人的关联联系人
contactController.shouldShowLinkedContacts = true;
[contactController viewDidLoad];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: contactController];
UIButton *cancelBtn = [UIButton buttonWithType: UIButtonTypeSystem];
cancelBtn.titleLabel.font = [UIFont systemFontOfSize:17];
[cancelBtn setTitle:@"取消" forState: UIControlStateNormal];
[cancelBtn addTarget:self action:@selector(dismissContactController) forControlEvents:UIControlEventTouchUpInside];
contactController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView: cancelBtn];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:nav animated:YES completion:nil];
}
- (void)dismissContactController {
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
@end
//
// ICContactsViewController.h
// superCleaner
//
// Created by Mazy on 2020/7/2.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactsViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// ICContactsBackupCell.h
// superCleaner
//
// Created by GY.Z on 2020/7/7.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class ICContactsBackup;
@interface ICContactsBackupCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIButton *button;
@property(nonatomic,strong)ICContactsBackup *model;
@end
NS_ASSUME_NONNULL_END
//
// ICContactsBackupCell.m
// superCleaner
//
// Created by GY.Z on 2020/7/7.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactsBackupCell.h"
#import "ICContactsBackup.h"
@interface ICContactsBackupCell ()
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *noteLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;
@end
@implementation ICContactsBackupCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)setModel:(ICContactsBackup *)model
{
_model = model;
self.dateLabel.text = [NSString stringWithFormat:@"%@",[self convertStrToTime:model.timestamp]];
self.noteLabel.text = [NSString stringWithFormat:@"%ldKB",(long)[model.kMDItemFSSize integerValue]/1000];
if (model.choose) {
[self.button setImage:[UIImage imageNamed:@"contact_choosed"] forState:UIControlStateNormal];
}else{
[self.button setImage:[UIImage imageNamed:@"contact_choose"] forState:UIControlStateNormal];
}
}
- (NSString *)convertStrToTime:(NSString *)timeStr
{
long long time=[timeStr longLongValue];
NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *timeString=[formatter stringFromDate:date];
return timeString;
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="ICContactsBackupCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sYw-tN-Bgp">
<rect key="frame" x="10" y="5" width="30" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="30" id="XKU-zC-N4D"/>
</constraints>
<state key="normal" image="contact_choose"/>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xfq-Eb-3tY">
<rect key="frame" x="295" y="0.0" width="0.0" height="50"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="global_cell_indicator" translatesAutoresizingMaskIntoConstraints="NO" id="5jw-ga-IMg">
<rect key="frame" x="300" y="20" width="10" height="10"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="BcT-QY-hl8"/>
<constraint firstAttribute="width" constant="10" id="lVn-SP-mGc"/>
</constraints>
</imageView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="lEa-Lz-5op">
<rect key="frame" x="45" y="11" width="163.5" height="28"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2020年7月7日 下午5:02:37" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Gu-nn-XRH">
<rect key="frame" x="0.0" y="0.0" width="163.5" height="16"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="35.9KB [张广义的 iPhone]" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zOK-Ma-fu3">
<rect key="frame" x="0.0" y="16" width="163.5" height="12"/>
<fontDescription key="fontDescription" type="system" pointSize="10"/>
<color key="textColor" white="0.59999999999999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="xfq-Eb-3tY" secondAttribute="bottom" id="AJl-LV-cWH"/>
<constraint firstAttribute="bottom" secondItem="sYw-tN-Bgp" secondAttribute="bottom" constant="5" id="EZ3-4u-txn"/>
<constraint firstItem="lEa-Lz-5op" firstAttribute="leading" secondItem="sYw-tN-Bgp" secondAttribute="trailing" constant="5" id="FrE-2n-WVY"/>
<constraint firstItem="lEa-Lz-5op" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="R8p-iH-dNz"/>
<constraint firstItem="sYw-tN-Bgp" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="UDR-TN-ghX"/>
<constraint firstItem="sYw-tN-Bgp" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="VVi-Aw-Exb"/>
<constraint firstItem="5jw-ga-IMg" firstAttribute="leading" secondItem="xfq-Eb-3tY" secondAttribute="trailing" constant="5" id="W1n-g6-9sS"/>
<constraint firstAttribute="trailing" secondItem="5jw-ga-IMg" secondAttribute="trailing" constant="10" id="eQ7-o6-Kyo"/>
<constraint firstItem="xfq-Eb-3tY" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="jCY-yD-IBh"/>
<constraint firstItem="sYw-tN-Bgp" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="lJs-cC-yiT"/>
<constraint firstItem="5jw-ga-IMg" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="sL2-Ff-AN4"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="button" destination="sYw-tN-Bgp" id="Qpx-IL-KeY"/>
<outlet property="countLabel" destination="xfq-Eb-3tY" id="1GP-4l-izg"/>
<outlet property="dateLabel" destination="4Gu-nn-XRH" id="cPt-KR-3F6"/>
<outlet property="noteLabel" destination="zOK-Ma-fu3" id="lf9-XQ-74c"/>
</connections>
<point key="canvasLocation" x="137.68115942028987" y="132.58928571428572"/>
</tableViewCell>
</objects>
<resources>
<image name="contact_choose" width="20" height="20"/>
<image name="global_cell_indicator" width="7" height="12"/>
</resources>
</document>
//
// ICContactsBackupHeader.h
// superCleaner
//
// Created by GY.Z on 2020/7/7.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactsBackupHeader : UIView
@end
NS_ASSUME_NONNULL_END
//
// ICContactsBackupHeader.m
// superCleaner
//
// Created by GY.Z on 2020/7/7.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactsBackupHeader.h"
#import "ICContactsTool.h"
@interface ICContactsBackupHeader ()
@property (strong, nonatomic) UISwitch *switchButton;
@end
@implementation ICContactsBackupHeader
-(instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self setupSubviews];
}
return self;
}
-(void)setupSubviews
{
UIView *line = [[UIView alloc] init];
line.backgroundColor = [UIColor colorWithHexString:@"#E5E7EB"];
[self addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(@30);
make.left.right.equalTo(@0);
make.height.equalTo(@0.5);
}];
UILabel *label = [[UILabel alloc] init];
label.text = ICLocalized(@"AutomaticBackup");
label.textColor = [UIColor colorWithHexString:@"#212121"];
label.font = [UIFont systemFontOfSize:16];
[self addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@16);
make.height.equalTo(@44);
make.top.equalTo(line.mas_bottom).offset(0);
}];
self.switchButton = [[UISwitch alloc] init];
[self addSubview:self.switchButton];
self.switchButton.on = NO;
self.switchButton.onTintColor = kMassColor;
[self.switchButton addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
[self.switchButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(label);
make.right.equalTo(@(-16));
}];
NSString *value = [[NSUserDefaults standardUserDefaults] objectForKey:@"auto_icloud_backup"];
if ([value isEqualToString:@"auto_backup"]) {
self.switchButton.on = YES;
}
UIView *bottomLine = [[UIView alloc] init];
bottomLine.backgroundColor = [UIColor colorWithHexString:@"#E5E7EB"];
[self addSubview:bottomLine];
[bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(@0);
make.top.equalTo(label.mas_bottom).offset(0);
make.height.equalTo(@0.5);
}];
UILabel *subLabel = [[UILabel alloc] init];
subLabel.text = ICLocalized(@"BackupDescription");
subLabel.numberOfLines = 2;
subLabel.textColor = [UIColor colorWithHexString:@"#858B9C"];
subLabel.textAlignment = NSTextAlignmentCenter;
subLabel.font = [UIFont systemFontOfSize:12];
[self addSubview:subLabel];
[subLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(@0);
make.height.equalTo(@30);
make.top.equalTo(bottomLine.mas_bottom).offset(0);
}];
}
- (void)switchAction:(UISwitch *)sender {
// sender.on = !sender.on;
if (sender.on) {
NSLog(@"自动备份");
[[NSUserDefaults standardUserDefaults] setObject:@"auto_backup" forKey:@"auto_icloud_backup"];
ICContactsTool *tools = [ICContactsTool shareInstance];
NSString *time = [tools getNowTimeTimestamp];
[tools synciCloudContactsFileName:time];
}else{
[[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"auto_icloud_backup"];
NSLog(@"取消");
}
}
@end
//
// ICContactsListCell.h
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class ICContactListModel;
@interface ICContactsListCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIButton *chooseBtn;
@property (weak, nonatomic) IBOutlet UIImageView *imageV;
@property (weak, nonatomic) IBOutlet UILabel *nameL;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imageLeftMargin;
@property (weak, nonatomic) IBOutlet UILabel *iconLabel;
@property(nonatomic,strong)ICContactListModel *model;
@property(nonatomic,assign)NSInteger chooseCount;
@end
NS_ASSUME_NONNULL_END
//
// ICContactsListCell.m
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactsListCell.h"
#import "ICContactListModel.h"
@interface ICContactsListCell ()
@end
@implementation ICContactsListCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.chooseBtn.hidden = YES;
}
-(void)setModel:(ICContactListModel *)model
{
_model = model;
self.nameL.text = [NSString stringWithFormat:@"%@%@",model.contact.familyName,model.contact.givenName];
if (model.contact.imageData != nil) {
self.imageV.image = [UIImage imageWithData:[NSData dataWithData:model.contact.imageData]];
self.iconLabel.text = @"";
}else{
self.imageV.image = [UIImage new];
if (model.contact.familyName.length) {
self.iconLabel.text = [model.contact.familyName substringToIndex:1];
}else if (model.contact.givenName.length){
self.iconLabel.text = [model.contact.givenName substringToIndex:1];
}
}
self.chooseBtn.hidden = model.choose;
if (model.choose) {
[self.chooseBtn setImage:[UIImage imageNamed:@"contact_choosed"] forState:UIControlStateNormal];
}else{
[self.chooseBtn setImage:[UIImage imageNamed:@"contact_choose"] forState:UIControlStateNormal];
}
}
-(void)setChooseCount:(NSInteger)chooseCount
{
_chooseCount = chooseCount;
if (chooseCount >= 1) {
self.imageLeftMargin.constant = 48;
self.chooseBtn.hidden = NO;
}else{
self.imageLeftMargin.constant = 16;
self.chooseBtn.hidden = YES;
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="ICContactsListCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PIs-tF-3ro">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" secondItem="PIs-tF-3ro" secondAttribute="height" multiplier="1:1" id="Zi5-NC-wPG"/>
</constraints>
<state key="normal" image="contact_choose"/>
</button>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="657-gx-XeG">
<rect key="frame" x="10" y="3" width="44" height="44"/>
<color key="backgroundColor" red="0.49803921568627452" green="0.53333333333333333" blue="0.60784313725490191" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="657-gx-XeG" secondAttribute="height" multiplier="1:1" id="J3S-Be-gcE"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="clipsToBounds" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="22"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="电话" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sZX-cl-YBp">
<rect key="frame" x="64" y="0.0" width="206" height="50"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dbw-qu-kii">
<rect key="frame" x="32" y="25" width="0.0" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" red="0.96862745100000003" green="0.96862745100000003" blue="0.96862745100000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="dbw-qu-kii" firstAttribute="centerX" secondItem="657-gx-XeG" secondAttribute="centerX" id="8C8-Fh-3u4"/>
<constraint firstItem="sZX-cl-YBp" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="EQb-Qd-JIs"/>
<constraint firstAttribute="bottom" secondItem="sZX-cl-YBp" secondAttribute="bottom" id="M2H-9z-jrO"/>
<constraint firstAttribute="bottom" secondItem="657-gx-XeG" secondAttribute="bottom" constant="3" id="PBM-A9-xxg"/>
<constraint firstAttribute="bottom" secondItem="PIs-tF-3ro" secondAttribute="bottom" id="Pwd-7n-pvS"/>
<constraint firstAttribute="trailing" secondItem="sZX-cl-YBp" secondAttribute="trailing" constant="50" id="YfA-fr-85E"/>
<constraint firstItem="657-gx-XeG" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="3" id="Z2A-zU-IJX"/>
<constraint firstItem="PIs-tF-3ro" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="a8X-nD-lhK"/>
<constraint firstItem="dbw-qu-kii" firstAttribute="centerY" secondItem="657-gx-XeG" secondAttribute="centerY" id="fTZ-kD-XHz"/>
<constraint firstItem="657-gx-XeG" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="mTj-fQ-GGa"/>
<constraint firstItem="PIs-tF-3ro" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="rY4-Rp-LdH"/>
<constraint firstItem="sZX-cl-YBp" firstAttribute="leading" secondItem="657-gx-XeG" secondAttribute="trailing" constant="10" id="u9o-HR-tKG"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="chooseBtn" destination="PIs-tF-3ro" id="cME-yu-2En"/>
<outlet property="iconLabel" destination="dbw-qu-kii" id="l5n-Sz-2FQ"/>
<outlet property="imageLeftMargin" destination="mTj-fQ-GGa" id="4Tr-3C-sdv"/>
<outlet property="imageV" destination="657-gx-XeG" id="8if-N3-iAI"/>
<outlet property="nameL" destination="sZX-cl-YBp" id="6Z0-BK-BGB"/>
</connections>
<point key="canvasLocation" x="139" y="102"/>
</tableViewCell>
</objects>
<resources>
<image name="contact_choose" width="20" height="20"/>
</resources>
</document>
//
// ICContactsRepeatCell.h
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class ICContactListModel;
@interface ICContactsRepeatCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@property (weak, nonatomic) IBOutlet UIButton *chooseButton;
@property (weak, nonatomic) IBOutlet UIView *contactView;
@property(nonatomic,strong)ICContactListModel *model;
@end
NS_ASSUME_NONNULL_END
//
// ICContactsRepeatCell.m
// superCleaner
//
// Created by GY.Z on 2020/7/4.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactsRepeatCell.h"
#import "UIColor+HExtension.h"
#import "ICContactListModel.h"
@implementation ICContactsRepeatCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.contactView.layer.borderColor = [UIColor colorWithHexString:@"#dddddd"].CGColor;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)setModel:(ICContactListModel *)model
{
_model = model;
self.nameLabel.text = [NSString stringWithFormat:@"%@%@", model.contact.familyName, model.contact.givenName];
if (model.contact.phoneNumbers.count) {
NSArray *phones = model.contact.phoneNumbers;
CNLabeledValue *labeledValue = phones[0];
CNPhoneNumber *phoneNumer = labeledValue.value;
NSString *phoneNumber = phoneNumer.stringValue;
self.phoneLabel.text = [NSString stringWithFormat:@"%@", phoneNumber];
}else{
self.phoneLabel.text = @"";
}
self.chooseButton.selected = model.choose;
if (model.choose) {
[self.chooseButton setImage:[UIImage imageNamed:@"contact_choosed"] forState:UIControlStateNormal];
}else{
[self.chooseButton setImage:[UIImage imageNamed:@"contact_choose"] forState:UIControlStateNormal];
}
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="ICContactsRepeatCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="70"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="70"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Pj1-TJ-iPf">
<rect key="frame" x="0.0" y="0.0" width="320" height="70"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Xqk-Mw-wbA">
<rect key="frame" x="16" y="5" width="288" height="60"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="68w-dd-tC1">
<rect key="frame" x="244" y="8" width="44" height="44"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="qbC-hY-nTd"/>
<constraint firstAttribute="height" constant="44" id="yMe-4u-wCZ"/>
</constraints>
<state key="normal" image="contact_choose"/>
</button>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="DSr-6j-m3h">
<rect key="frame" x="10" y="13" width="86.5" height="34"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="张" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wMf-Wd-FmU">
<rect key="frame" x="0.0" y="0.0" width="86.5" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.13333333333333333" green="0.16078431372549018" blue="0.23921568627450979" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="18211128646" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1mM-QU-4ZB">
<rect key="frame" x="0.0" y="17" width="86.5" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.13333333333333333" green="0.16078431372549018" blue="0.23921568627450979" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="68w-dd-tC1" firstAttribute="centerY" secondItem="Xqk-Mw-wbA" secondAttribute="centerY" id="216-Vz-PJi"/>
<constraint firstItem="DSr-6j-m3h" firstAttribute="centerY" secondItem="Xqk-Mw-wbA" secondAttribute="centerY" id="R13-Os-mAw"/>
<constraint firstAttribute="trailing" secondItem="68w-dd-tC1" secondAttribute="trailing" id="R96-4s-dbL"/>
<constraint firstItem="DSr-6j-m3h" firstAttribute="leading" secondItem="Xqk-Mw-wbA" secondAttribute="leading" constant="10" id="TIk-k0-EjU"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="clipsToBounds" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="8"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
<integer key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<color key="backgroundColor" red="0.9137254901960784" green="0.97254901960784312" blue="0.93333333333333335" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Xqk-Mw-wbA" secondAttribute="trailing" constant="16" id="6KY-Q9-JDf"/>
<constraint firstAttribute="bottom" secondItem="Xqk-Mw-wbA" secondAttribute="bottom" constant="5" id="MZx-Yv-9qu"/>
<constraint firstItem="Xqk-Mw-wbA" firstAttribute="leading" secondItem="Pj1-TJ-iPf" secondAttribute="leading" constant="16" id="VVS-V4-v5v"/>
<constraint firstItem="Xqk-Mw-wbA" firstAttribute="top" secondItem="Pj1-TJ-iPf" secondAttribute="top" constant="5" id="xbF-EF-q8B"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="massBackgroundColorWithAlpha">
<real key="value" value="0.14999999999999999"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="Pj1-TJ-iPf" secondAttribute="trailing" id="CuA-eC-Q30"/>
<constraint firstAttribute="bottom" secondItem="Pj1-TJ-iPf" secondAttribute="bottom" id="HPZ-OO-C7I"/>
<constraint firstItem="Pj1-TJ-iPf" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="JLk-Zr-Kvd"/>
<constraint firstItem="Pj1-TJ-iPf" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="Oam-F3-DVp"/>
</constraints>
</tableViewCellContentView>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<connections>
<outlet property="chooseButton" destination="68w-dd-tC1" id="Z0J-w4-PED"/>
<outlet property="contactView" destination="Xqk-Mw-wbA" id="hLh-E6-hl4"/>
<outlet property="nameLabel" destination="wMf-Wd-FmU" id="cCq-06-Gy0"/>
<outlet property="phoneLabel" destination="1mM-QU-4ZB" id="27c-Xv-A02"/>
</connections>
<point key="canvasLocation" x="137.68115942028987" y="87.723214285714278"/>
</tableViewCell>
</objects>
<resources>
<image name="contact_choose" width="22" height="22"/>
</resources>
</document>
//
// ICContactsRepeatHeader.h
// superCleaner
//
// Created by GY.Z on 2020/7/6.
// Copyright © 2020 Mazy. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ICContactsRepeatHeader : UITableViewHeaderFooterView
@property(nonatomic,strong)UIButton *selectBtn;
@property(nonatomic,strong)NSArray *contacts;
-(void)updateName:(NSString *)name updatePhone:(NSString *)phone;
@end
NS_ASSUME_NONNULL_END
//
// ICContactsRepeatHeader.m
// superCleaner
//
// Created by GY.Z on 2020/7/6.
// Copyright © 2020 Mazy. All rights reserved.
//
#import "ICContactsRepeatHeader.h"
#import "ICContactListModel.h"
#import <Contacts/Contacts.h>
#import "ICContactsTool.h"
#define kWidth [UIScreen mainScreen].bounds.size.width
#define kHeight [UIScreen mainScreen].bounds.size.height
@interface ICContactsRepeatHeader ()
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong)UIView *contView;
@property(nonatomic,strong)UIView *baseView;
@property(nonatomic,strong)UILabel *nameLabel;
@property(nonatomic,strong)UILabel *phoneLabel;
@end
@implementation ICContactsRepeatHeader
-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
self.contentView.backgroundColor = [UIColor whiteColor];
self.contView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, kWidth - 32, 120)];
self.contView.backgroundColor = kMassColorAlpha(0.1);
[self.contentView addSubview:self.contView];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.contView.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = self.contView.bounds;
maskLayer.path = maskPath.CGPath;
self.contView.layer.mask = maskLayer;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
[self.contView addGestureRecognizer:tap];
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.text = ICLocalized(@"MergedContact");
self.titleLabel.font = [UIFont systemFontOfSize:14];
[self.contView addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(@16);
}];
self.selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[self.selectBtn setTitle:ICLocalized(@"ChooseAll") forState:UIControlStateNormal];
[self.selectBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
[self.selectBtn setTitleColor:kMassColor forState:UIControlStateNormal];
[self.contView addSubview:self.selectBtn];
[self.selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(@(-16));
make.top.equalTo(@14);
}];
self.baseView = [[UIView alloc] init];
self.baseView.backgroundColor = kMassColorAlpha(0.3);
[self.contView addSubview:self.baseView];
[self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@16);
make.top.equalTo(@46);
make.right.equalTo(@(-16));
make.height.equalTo(@60);
}];
self.baseView.layer.cornerRadius = 8;
self.nameLabel = [[UILabel alloc] init];
self.nameLabel.text = ICLocalized(@"Name");
self.nameLabel.font = [UIFont systemFontOfSize:14];
[self.baseView addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(@12);
}];
self.phoneLabel = [[UILabel alloc] init];
self.phoneLabel.text = ICLocalized(@"Phone");
self.phoneLabel.font = [UIFont systemFontOfSize:14];
[self.baseView addSubview:self.phoneLabel];
[self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@12);
make.top.equalTo(self.nameLabel.mas_bottom).offset(3);
}];
}
return self;
}
-(void)setContacts:(NSArray *)contacts
{
_contacts = contacts;
NSArray *array = contacts;
NSString *name = @"";
NSString *phone = @"";
NSString *subPhone = @"";
NSInteger idx = 0;
[self.selectBtn setTitle:ICLocalized(@"CancelAll") forState:UIControlStateNormal];
for (ICContactListModel *model in array) {
subPhone = [subPhone stringByAppendingFormat:@"%@ ",model.contact.familyName];
if (model.contact.phoneNumbers.count) {
NSArray *phones = model.contact.phoneNumbers;
CNLabeledValue *labeledValue = phones[0];
CNPhoneNumber *phoneNumer = labeledValue.value;
NSString *phoneNumber = phoneNumer.stringValue;
phone = [NSString stringWithFormat:@"%@", phoneNumber];
}
if (model.choose) {
idx ++;
name = [name stringByAppendingFormat:@"%@ ",model.contact.familyName];
}else{
[self.selectBtn setTitle:ICLocalized(@"ChooseAll") forState:UIControlStateNormal];
}
}
if (idx > 1) {
[self updateName:name updatePhone:phone];
}else{
[self updateName:subPhone updatePhone:phone];
}
}
-(void)updateName:(NSString *)name updatePhone:(NSString *)phone
{
self.nameLabel.text = name;
self.phoneLabel.text = phone;
}
-(void)tapAction
{
NSLog(@"click");
if (self.contacts.count == 0) return ;
ICContactListModel *model = self.contacts[0];
[ICContactsTool shareInstance].note = self.nameLabel.text;
[[ICContactsTool shareInstance] enterContactsDetail:model.contact controller:[self getViewController] push:NO];
}
- (UIViewController *)getViewController {
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder* nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController*)nextResponder;
}
}
return nil;
}
@end
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#import "ICNetworkSpeedViewController.h" #import "ICNetworkSpeedViewController.h"
#import "ICBatteryCareViewController.h" #import "ICBatteryCareViewController.h"
#import "ICPhotoManageViewController.h" #import "ICPhotoManageViewController.h"
#import "ICContactsViewController.h"
#import "ICCalendarManageController.h" #import "ICCalendarManageController.h"
#import "StatisticsViewController.h" #import "StatisticsViewController.h"
#import "SCHomeHeaderView.h" #import "SCHomeHeaderView.h"
...@@ -41,13 +40,12 @@ ...@@ -41,13 +40,12 @@
[super viewDidLoad]; [super viewDidLoad];
_dataSource = @[@{@"image":@"home_cell_0", @"title":@"照片和视频", @"details":@"清除相似照片与视频"}, _dataSource = @[@{@"image":@"home_cell_0", @"title":@"照片和视频", @"details":@"清除相似照片与视频"},
@{@"image":@"home_cell_1", @"title":@"联系人", @"details":@"清除重复·备份联系人"},
@{@"image":@"home_cell_2", @"title":@"日历和提醒事项", @"details":@"清理过期提醒事项"}, @{@"image":@"home_cell_2", @"title":@"日历和提醒事项", @"details":@"清理过期提醒事项"},
@{@"image":@"home_cell_3", @"title":@"手机清灰", @"details":@"除尘·修复听筒音量"}, @{@"image":@"home_cell_3", @"title":@"手机清灰", @"details":@"除尘·修复听筒音量"},
@{@"image":@"home_cell_4", @"title":@"网速检测", @"details":@"一键测试你的网络速度"}, @{@"image":@"home_cell_4", @"title":@"网速检测", @"details":@"一键测试你的网络速度"},
@{@"image":@"home_cell_5", @"title":@"分贝检测", @"details":@"专业的噪音检测仪"}, @{@"image":@"home_cell_5", @"title":@"分贝检测", @"details":@"专业的噪音检测仪"},
@{@"image":@"home_cell_6", @"title":@"电池寿命", @"details":@"延长iPhone电池寿命"}, @{@"image":@"home_cell_6", @"title":@"电池寿命", @"details":@"延长iPhone电池寿命"},
@{@"image":@"home_cell_7", @"title":@"相册统计", @"details":@"种类占比"}]; /*@{@"image":@"home_cell_7", @"title":@"相册统计", @"details":@"种类占比"}*/];
[self setupUI]; [self setupUI];
...@@ -315,19 +313,12 @@ ...@@ -315,19 +313,12 @@
} }
break; break;
case 1: case 1:
{
[MobClick event:@"contact_click"];
ICContactsViewController *contactVC = [[ICContactsViewController alloc] init];
[self.navigationController pushViewController:contactVC animated:true];
}
break;
case 2:
{ {
ICCalendarManageController *calendarVC = [[ICCalendarManageController alloc] init]; ICCalendarManageController *calendarVC = [[ICCalendarManageController alloc] init];
[self.navigationController pushViewController:calendarVC animated:true]; [self.navigationController pushViewController:calendarVC animated:true];
} }
break; break;
case 3: case 2:
{ {
if ([ICUserManager shared].isMember) { if ([ICUserManager shared].isMember) {
ICCleanDustViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICCleanDustViewController"]; ICCleanDustViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICCleanDustViewController"];
...@@ -339,7 +330,7 @@ ...@@ -339,7 +330,7 @@
} }
} }
break; break;
case 4: case 3:
{ {
if ([ICUserManager shared].isMember) { if ([ICUserManager shared].isMember) {
ICNetworkSpeedViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICNetworkSpeedViewController"]; ICNetworkSpeedViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICNetworkSpeedViewController"];
...@@ -351,7 +342,7 @@ ...@@ -351,7 +342,7 @@
} }
} }
break; break;
case 5: case 4:
{ {
if ([ICUserManager shared].isMember) { if ([ICUserManager shared].isMember) {
ICDbTestViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICDbTestViewController"]; ICDbTestViewController *vc = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICDbTestViewController"];
...@@ -363,17 +354,23 @@ ...@@ -363,17 +354,23 @@
} }
} }
break; break;
case 6: case 5:
{ {
if ([ICUserManager shared].isMember) {
ICBatteryCareViewController *vc = [[ICBatteryCareViewController alloc] init]; ICBatteryCareViewController *vc = [[ICBatteryCareViewController alloc] init];
[self.navigationController pushViewController:vc animated:true]; [self.navigationController pushViewController:vc animated:true];
}else {
ICIAPViewController *iapVC = [[UIStoryboard storyboardWithName:@"Main" bundle: nil] instantiateViewControllerWithIdentifier:@"ICIAPViewController"];
ICNavigationController *navc = [[ICNavigationController alloc] initWithRootViewController:iapVC];
[self presentViewController:navc animated:true completion:nil];
} }
break;
case 7:{
StatisticsViewController * statistics = [[StatisticsViewController alloc] init];
[self.navigationController pushViewController:statistics animated:YES];
} }
break; break;
// case 7:{
// StatisticsViewController * statistics = [[StatisticsViewController alloc] init];
// [self.navigationController pushViewController:statistics animated:YES];
// }
break;
default: default:
break; break;
} }
......
...@@ -18,7 +18,6 @@ typedef void(^SelectionClosure)(BOOL granted); ...@@ -18,7 +18,6 @@ typedef void(^SelectionClosure)(BOOL granted);
@interface ICContactsIncompleteCell : UITableViewCell @interface ICContactsIncompleteCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameLabel; @property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UIButton *chooseBtn; @property (weak, nonatomic) IBOutlet UIButton *chooseBtn;
@property(nonatomic,strong)ICContactListModel *model;
@property (weak, nonatomic) IBOutlet UILabel *subTitleLabel; @property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;
@property (nonatomic, strong) NSDateFormatter *formatter; @property (nonatomic, strong) NSDateFormatter *formatter;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
// //
#import "ICContactsIncompleteCell.h" #import "ICContactsIncompleteCell.h"
#import "ICContactListModel.h"
@implementation ICContactsIncompleteCell @implementation ICContactsIncompleteCell
...@@ -23,18 +22,6 @@ ...@@ -23,18 +22,6 @@
// Configure the view for the selected state // Configure the view for the selected state
} }
-(void)setModel:(ICContactListModel *)model
{
_model = model;
self.nameLabel.text = [NSString stringWithFormat:@"%@%@", model.contact.familyName, model.contact.givenName];
self.chooseBtn.selected = model.choose;
if (model.choose) {
[self.chooseBtn setImage:[UIImage imageNamed:@"contact_choosed"] forState:UIControlStateNormal];
}else{
[self.chooseBtn setImage:[UIImage imageNamed:@"contact_choose"] forState:UIControlStateNormal];
}
}
-(void)configWithEvent: (EKEvent *)event seleted: (BOOL)isSelected { -(void)configWithEvent: (EKEvent *)event seleted: (BOOL)isSelected {
self.subTitleLabel.text = event.title; self.subTitleLabel.text = event.title;
self.subTitleLabel.hidden = false; self.subTitleLabel.hidden = false;
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
<string>Super Cleaner 需要访问您的日历权限才能管理你的过期日历</string> <string>Super Cleaner 需要访问您的日历权限才能管理你的过期日历</string>
<key>NSCameraUsageDescription</key> <key>NSCameraUsageDescription</key>
<string>Super Cleaner 需要访问您的相机权限才能分析相似图片和视频</string> <string>Super Cleaner 需要访问您的相机权限才能分析相似图片和视频</string>
<key>NSContactsUsageDescription</key>
<string>Super Cleaner 需要访问您的通讯录权限才能备份和恢复您的联系人</string>
<key>NSMicrophoneUsageDescription</key> <key>NSMicrophoneUsageDescription</key>
<string>Super Cleaner 需要访问您的麦克风才能进行分贝检测</string> <string>Super Cleaner 需要访问您的麦克风才能进行分贝检测</string>
<key>NSPhotoLibraryUsageDescription</key> <key>NSPhotoLibraryUsageDescription</key>
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#import "ICCalenderReminderController.h" #import "ICCalenderReminderController.h"
#import "WMEventCalendarTool.h" #import "WMEventCalendarTool.h"
#import "ICCalendarEventViewCell.h"
#import "ICContactsIncompleteCell.h" #import "ICContactsIncompleteCell.h"
@interface ICCalenderReminderController ()<UITableViewDataSource, UITableViewDelegate> @interface ICCalenderReminderController ()<UITableViewDataSource, UITableViewDelegate>
......
...@@ -4,22 +4,7 @@ ...@@ -4,22 +4,7 @@
<dict> <dict>
<key>aps-environment</key> <key>aps-environment</key>
<string>development</string> <string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.com.app.superCleanMaster</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
<string>CloudKit</string>
</array>
<key>com.apple.developer.networking.wifi-info</key> <key>com.apple.developer.networking.wifi-info</key>
<true/> <true/>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>iCloud.com.app.superCleanMaster</string>
</array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
</dict> </dict>
</plist> </plist>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment