Skip to content

Commit

Permalink
修复demoVC3内存泄露问题,新增清理缓存类,优化代码结构!
Browse files Browse the repository at this point in the history
  • Loading branch information
boai committed Jul 14, 2016
1 parent 9d6aaa2 commit c721b0f
Show file tree
Hide file tree
Showing 62 changed files with 314 additions and 328 deletions.
176 changes: 92 additions & 84 deletions BABaseProject.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

#import "DemoVC12View.h"
#import "BAPayPwdInputView.h"

static NSString * const titleMsg = @"欢迎使用 iPhone SE,迄今最高性能的 4 英寸 iPhone。在打造这款手机时,我们在深得人心的 4 英寸设计基础上,从里到外重新构想。它所采用的 A9 芯片,正是在 iPhone 6s 上使用的先进芯片。1200 万像素的摄像头能拍出令人叹为观止的精彩照片和 4K 视频,而 Live Photos 则会让你的照片栩栩如生。这一切,成就了一款外形小巧却异常强大的 iPhone。";
@interface DemoVC12View ()
Expand All @@ -26,7 +25,6 @@ @interface DemoVC12View ()
@property (nonatomic, strong) BACustomButton *button4;
@property (nonatomic, strong) BACustomButton *sureButton;

@property (nonatomic, strong) BAPayPwdInputView *payPwdView;


@end
Expand Down Expand Up @@ -59,7 +57,13 @@ - (NSArray *)titleArray
{
if (!_titleArray)
{
_titleArray = @[@"1、自定义弹窗1", @"2、自定义弹窗2【带图片,按钮】", @"3、自定义警告框3【类似系统警告框, 不带button】", @"4、自定义警告框4【类似系统警告框, 带延时】", @"5、自定义警告框5【类似系统警告框, 带图片,按钮】", @"6、系统警告框6【兼容iOS 7、8】", @"7、系统ActionSheet【兼容iOS 7、8】"];
_titleArray = @[@"1、自定义弹窗1",
@"2、自定义弹窗2【带图片,按钮】",
@"3、自定义警告框3【类似系统警告框, 不带button】",
@"4、自定义警告框4【类似系统警告框, 带延时】",
@"5、自定义警告框5【类似系统警告框, 带图片,按钮】",
@"6、系统警告框6【兼容iOS 7、8】",
@"7、系统ActionSheet【兼容iOS 7、8】"];
}
return _titleArray;
}
Expand Down Expand Up @@ -132,16 +136,15 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath

- (void)alert1
{
if (!_modal1)
{
_modal1 = [self creatModal:nil];
}

self.bgView.hidden = NO;
// self.payPwdView.hidden = NO;

[_modal1 showContentView:_bgView animated:YES];
// [_modal1 showContentView:_payPwdView animated:YES];
BALog(@"此方法待调试!");
// if (!_modal1)
// {
// _modal1 = [self creatModal:nil];
// }
//
// self.bgView.hidden = NO;
//
// [_modal1 showContentView:_bgView animated:YES];
}

- (void)alert2
Expand Down Expand Up @@ -170,7 +173,7 @@ - (void)alert2
}
if (index == 1)
{
BA_OpenUrl([NSURL URLWithString:@"http://boai.github.io"]);
BA_OpenUrl(@"http://boai.github.io");
}
}];
[alert show:YES];
Expand All @@ -197,7 +200,7 @@ - (void)alert5
}
if (index == 1)
{
BA_OpenUrl([NSURL URLWithString:@"http://boai.github.io"]);
BA_OpenUrl(@"http://boai.github.io");
}

}];
Expand All @@ -214,7 +217,7 @@ - (void)alert6
}
if (index == 1)
{
BA_OpenUrl([NSURL URLWithString:@"http://boai.github.io"]);
BA_OpenUrl(@"http://boai.github.io");
}

}];
Expand All @@ -231,7 +234,7 @@ - (void)ActionSheet1
}
if (index == 1)
{
BA_OpenUrl([NSURL URLWithString:@"http://boai.github.io"]);
BA_OpenUrl(@"http://boai.github.io");
}
if (index == 2)
{
Expand Down Expand Up @@ -268,7 +271,7 @@ - (UIView *)bgView
{
_bgView = [UIView new];
_bgView.frame = CGRectMake(10, self.tableView.centerX, BA_SCREEN_WIDTH - 20, 200);
_bgView.backgroundColor = BA_White_Color;
_bgView.backgroundColor = BA_Green_Color;
_bgView.layer.masksToBounds = YES;
_bgView.clipsToBounds = YES;
_bgView.layer.cornerRadius = 8.0f;
Expand Down Expand Up @@ -397,16 +400,7 @@ - (IBAction)buttonAction:(UIButton *)sender

}

- (BAPayPwdInputView *)payPwdView
{
if (!_payPwdView)
{
_payPwdView = [[BAPayPwdInputView alloc] init];
_payPwdView.frame = CGRectMake(20, 20, BA_SCREEN_WIDTH - 40, 44);
_payPwdView.backgroundColor = [UIColor redColor];
}
return _payPwdView;
}



@end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ - (void)viewWillDisappear:(BOOL)animated
[super viewWillDisappear:animated];

[self isShowSnowLoadingView:NO];

}

- (void)viewDidLoad {
Expand All @@ -38,38 +37,23 @@ - (void)viewDidLoad {

- (void)clearCache
{
CGFloat cacheSize = [[SDImageCache sharedImageCache] getSize];

NSString *clearMessage = cacheSize >= 1024*1024 ? [NSString stringWithFormat:@"清理缓存(%.2fM)", cacheSize / 1024 / 1024] : [NSString stringWithFormat:@"清理缓存(%.2fK)", cacheSize / 1024];
BAClearCacheManager *clearCacheManager = [BAClearCacheManager ba_sharedCache];
CGFloat cacheSize = [clearCacheManager ba_loadCacheSize];

NSString *clearMessage = [@"需要清除缓存 " stringByAppendingFormat:@"%.2fM ?", cacheSize];

BA_Weak;
[self BAAlertWithTitle:@"温馨提示:" message:clearMessage andOthers:@[@"确 定"] animated:YES action:^(NSInteger index) {

if (index == 0)
{
// 清除内存缓存
[[[SDWebImageManager sharedManager] imageCache] clearMemory];
// 清除系统缓存
[[NSURLCache sharedURLCache] removeAllCachedResponses];

// [[[SDWebImageManager sharedManager] imageCache] cleanDisk];
[clearCacheManager ba_myClearCacheAction];
NSString *msg = [NSString stringWithFormat:@"成功清除缓存:%.2fM", cacheSize];
[weakSelf.view ba_showAlertView:@"温馨提示:" message:msg];
}

}];

}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ @interface DemoVC3 ()

@implementation DemoVC3

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[_headerLine stop];
}

- (void)viewDidLoad
{
[super viewDidLoad];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ - (BACustomButton *)QQLoginBtn
_QQLoginBtn.titleLabel.textAlignment = NSTextAlignmentRight;

[self.view addSubview:_QQLoginBtn];
[_QQLoginBtn ba_pulseViewWithTime:20];
[_QQLoginBtn ba_pulseViewWithTime:5];

}
return _QQLoginBtn;
Expand Down Expand Up @@ -97,8 +97,7 @@ - (IBAction)clickShareBtn:(UIButton *)sender
#pragma mark 友盟登陆BAShareManageDelegate
- (void)getUserData:(NSDictionary *)backUserData
{
BA_Weak;
[weakSelf.view ba_showAlertView:@"温馨提示:" message:[NSString stringWithFormat:@"友盟登陆成功,返回信息: %@", backUserData]];
[self.view ba_showAlertView:@"温馨提示:" message:[NSString stringWithFormat:@"友盟登陆成功,返回信息: %@", backUserData]];
BALog(@"友盟登陆成功,返回信息: %@", backUserData);
}

Expand Down
Loading

0 comments on commit c721b0f

Please sign in to comment.