为什么 AppDelegate 和台风的行为不同?
Why behaviour from AppDelegate and via typhoon is different?
我想将状态栏的样式设置为:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
如果我直接从 AppDelegate 执行 - 一切正常,但通过 Typhoon - 不行。
1) 一切正常:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[self styleKit] apply];
[self.window makeKeyAndVisible];
return YES;
}
2) 这不起作用:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}
-(void)initialize {
[[self styleKit] apply];
[self.window makeKeyAndVisible];
}
第二种方式我使用台风,例如:
@implementation LAMainAssembly
-(AppDelegate *)appDelegate {
return [TyphoonDefinition withClass:[AppDelegate class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(window) with:[self mainWindow]];
[definition injectProperty:@selector(styleKit)];
[definition performAfterInjections:@selector(initialize)];
}];
}
@end
在这两种情况下,我都使用相同的高级版本的样式,其中有一个:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
我认为这是因为 Typhoon 在 didFinishLaunchingWithOptions
之前开始它的初始化。
我建议避免依赖 Typhoon
初始化顺序,并在调用 didFinishLaunchingWithOptions
方法(你的第一种方法)后进行任何 UI 显式设置
我想将状态栏的样式设置为:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
如果我直接从 AppDelegate 执行 - 一切正常,但通过 Typhoon - 不行。
1) 一切正常:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[self styleKit] apply];
[self.window makeKeyAndVisible];
return YES;
}
2) 这不起作用:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}
-(void)initialize {
[[self styleKit] apply];
[self.window makeKeyAndVisible];
}
第二种方式我使用台风,例如:
@implementation LAMainAssembly
-(AppDelegate *)appDelegate {
return [TyphoonDefinition withClass:[AppDelegate class] configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(window) with:[self mainWindow]];
[definition injectProperty:@selector(styleKit)];
[definition performAfterInjections:@selector(initialize)];
}];
}
@end
在这两种情况下,我都使用相同的高级版本的样式,其中有一个:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
我认为这是因为 Typhoon 在 didFinishLaunchingWithOptions
之前开始它的初始化。
我建议避免依赖 Typhoon
初始化顺序,并在调用 didFinishLaunchingWithOptions
方法(你的第一种方法)后进行任何 UI 显式设置