Skip to content

Commit e270539

Browse files
committed
feat(all): 删除repairException方法,由主动调用修改为静默执行
1 parent 9d47f20 commit e270539

File tree

3 files changed

+18
-36
lines changed

3 files changed

+18
-36
lines changed

Demo/LLDynamicLaunchScreen/ViewController.m

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,21 @@ - (void)viewDidLoad {
3535
[button addTarget:self action:@selector(buttonEvent) forControlEvents:UIControlEventTouchUpInside];
3636

3737
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeSystem];
38-
[button1 setTitle:@"修复异常" forState:UIControlStateNormal];
38+
[button1 setTitle:@"恢复如初" forState:UIControlStateNormal];
3939
[button1 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
4040
button1.backgroundColor = [UIColor colorWithRed:14.0 / 255.0 green:144.0 / 255.0 blue:1.0 alpha:1.0];
4141
[self.view addSubview:button1];
4242
button1.frame = CGRectMake((screenWidth - 220) / 2.0, CGRectGetMaxY(button.frame) + 40.0, 220, 80);
4343
[button1 addTarget:self action:@selector(button1Event) forControlEvents:UIControlEventTouchUpInside];
4444

4545
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeSystem];
46-
[button2 setTitle:@"恢复如初" forState:UIControlStateNormal];
46+
[button2 setTitle:@"恢复指定启动图" forState:UIControlStateNormal];
4747
[button2 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
4848
button2.backgroundColor = [UIColor colorWithRed:14.0 / 255.0 green:144.0 / 255.0 blue:1.0 alpha:1.0];
4949
[self.view addSubview:button2];
5050
button2.frame = CGRectMake((screenWidth - 220) / 2.0, CGRectGetMaxY(button1.frame) + 40.0, 220, 80);
5151
[button2 addTarget:self action:@selector(button2Event) forControlEvents:UIControlEventTouchUpInside];
5252

53-
UIButton *button3 = [UIButton buttonWithType:UIButtonTypeSystem];
54-
[button3 setTitle:@"恢复指定启动图" forState:UIControlStateNormal];
55-
[button3 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
56-
button3.backgroundColor = [UIColor colorWithRed:14.0 / 255.0 green:144.0 / 255.0 blue:1.0 alpha:1.0];
57-
[self.view addSubview:button3];
58-
button3.frame = CGRectMake((screenWidth - 220) / 2.0, CGRectGetMaxY(button2.frame) + 40.0, 220, 80);
59-
[button3 addTarget:self action:@selector(button3Event) forControlEvents:UIControlEventTouchUpInside];
60-
6153
UILabel *alertLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
6254
self.alertLabel = alertLabel;
6355
alertLabel.center = self.view.center;
@@ -78,18 +70,12 @@ - (void)buttonEvent {
7870
}
7971

8072
- (void)button1Event {
81-
[LLDynamicLaunchScreen repairException];
82-
83-
[self showAlertView:@"修复启动图异常,APP即将退出"];
84-
}
85-
86-
- (void)button2Event {
8773
[LLDynamicLaunchScreen restoreAsBefore];
8874

8975
[self showAlertView:@"启动图已恢复,APP即将退出"];
9076
}
9177

92-
- (void)button3Event {
78+
- (void)button2Event {
9379
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"请选择替换方式" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
9480
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"恢复浅色竖屏启动图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
9581
[LLDynamicLaunchScreen replaceLaunchImage:nil launchImageType:LLLaunchImageTypeVerticalLight compressionQuality:0.8 validation:nil];

LLDynamicLaunchScreen/LLDynamicLaunchScreen.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ typedef NS_ENUM(NSInteger, LLLaunchImageType) {
3939
+ (nullable UIImage *)launchImageFromType:(LLLaunchImageType)launchImageType;
4040

4141

42-
/**
43-
修复启动图不显示等异常情况
44-
45-
@discussion 此操作是安全的,不会丢失已修改的启动图
46-
*/
47-
+ (void)repairException;
48-
49-
5042
/**
5143
将所有启动图恢复为默认启动图
5244

LLDynamicLaunchScreen/LLDynamicLaunchScreen.m

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ + (void)didFinishLaunching {
4545
}
4646
}
4747
} identifier:NSStringFromSelector(@selector(didFinishLaunching))];
48+
49+
[self repairException];
4850
}
4951

5052
+ (void)initialize {
@@ -71,6 +73,7 @@ + (void)initialize {
7173
[versionDictionary setObject:@"YES" forKey:NSStringFromSelector(@selector(didFinishLaunching))];
7274
[versionDictionary setObject:@"YES" forKey:NSStringFromSelector(@selector(initialization))];
7375
[versionDictionary setObject:@"YES" forKey:NSStringFromSelector(@selector(backupSystemLaunchImage))];
76+
[versionDictionary setObject:@"YES" forKey:NSStringFromSelector(@selector(repairException))];
7477

7578
[NSUserDefaults.standardUserDefaults setObject:versionDictionary.copy forKey:launchImageVersionIdentifier];
7679

@@ -157,19 +160,20 @@ + (void)replaceHorizontalLaunchImage:(nullable UIImage *)horizontalImage {
157160
}
158161

159162
+ (void)repairException {
160-
if (doesExistsOriginLaunchImage()) {
161-
NSDictionary *modifyDictionary = [NSUserDefaults.standardUserDefaults objectForKey:launchImageModifyIdentifier];
162-
for (NSString *key in modifyDictionary) {
163-
NSString *isModify = modifyDictionary[key];
164-
if ([isModify isEqualToString:@"NO"]) {
165-
[self replaceLaunchImage:nil launchImageType:LaunchImageTypeFromLaunchImageName(key) compressionQuality:0.8 validation:nil];
163+
[self launchImageIsNewVersion:^{
164+
if (doesExistsOriginLaunchImage()) {
165+
NSDictionary *modifyDictionary = [NSUserDefaults.standardUserDefaults objectForKey:launchImageModifyIdentifier];
166+
for (NSString *key in modifyDictionary) {
167+
NSString *isModify = modifyDictionary[key];
168+
if ([isModify isEqualToString:@"NO"]) {
169+
[self replaceLaunchImage:nil launchImageType:LaunchImageTypeFromLaunchImageName(key) compressionQuality:0.8 validation:nil];
170+
}
166171
}
172+
launchImage_repairException = NO;
173+
} else {
174+
launchImage_repairException = YES;
167175
}
168-
169-
launchImage_repairException = NO;
170-
} else {
171-
launchImage_repairException = YES;
172-
}
176+
} identifier:NSStringFromSelector(@selector(repairException))];
173177
}
174178

175179
+ (void)restoreAsBefore {

0 commit comments

Comments
 (0)