|
|
@@ -21,25 +21,14 @@
|
|
|
#import <AMapFoundationKit/AMapFoundationKit.h>
|
|
|
|
|
|
@interface AppDelegate () <HJWelcomeViewDelegate>
|
|
|
-@property (nonatomic, strong) HJLoginViewController *loginViewController;
|
|
|
-@property (nonatomic, strong) HJMainViewController *mainViewController;
|
|
|
-@property (nonatomic, strong) UILabel *launchVersionLabel;
|
|
|
-@property (nonatomic, strong) UIButton *launchStartButton;
|
|
|
-@property (nonatomic, strong) HJWelcomeViewController *welcomeViewController;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation AppDelegate
|
|
|
|
|
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
|
|
- //设置你工程的启动页使用的是:LaunchImage 还是 LaunchScreen.storyboard(不设置默认:LaunchImage)
|
|
|
- [XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
|
|
|
//配置广告数据
|
|
|
- XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
|
|
|
- imageAdconfiguration.duration = 3;
|
|
|
- imageAdconfiguration.subViews = @[self.launchVersionLabel, self.launchStartButton];
|
|
|
- imageAdconfiguration.skipButtonType = SkipTypeNone;
|
|
|
- imageAdconfiguration.showFinishAnimate = ShowFinishAnimateLite;
|
|
|
- [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
|
|
|
+ [self setupAd];
|
|
|
|
|
|
// 高德地图
|
|
|
[AMapServices sharedServices].apiKey = kGAODEAPIKey;
|
|
|
@@ -60,12 +49,26 @@
|
|
|
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
|
|
self.window.backgroundColor = [UIColor whiteColor];
|
|
|
- self.window.rootViewController = self.welcomeViewController.isShow ? self.welcomeViewController : [self setupFirstViewController];
|
|
|
+ HJWelcomeViewController *welcomeViewController = [[HJWelcomeViewController alloc] init];
|
|
|
+ welcomeViewController.delegate = self;
|
|
|
+ if (welcomeViewController.isShow) {
|
|
|
+ self.window.rootViewController = welcomeViewController;
|
|
|
+ } else {
|
|
|
+ self.window.rootViewController = [self setupFirstViewController];
|
|
|
+ }
|
|
|
[self.window makeKeyAndVisible];
|
|
|
|
|
|
return YES;
|
|
|
}
|
|
|
+//iOS 9 之前用
|
|
|
+- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
|
|
|
+ return [WXApi handleOpenURL:url delegate:[HJWeiXinAPIManager sharedManager]];
|
|
|
+}
|
|
|
|
|
|
+- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
|
|
|
+ return [WXApi handleOpenURL:url delegate:[HJWeiXinAPIManager sharedManager]];
|
|
|
+}
|
|
|
+//iOS 9之后用
|
|
|
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
|
|
|
return [WXApi handleOpenURL:url delegate:[HJWeiXinAPIManager sharedManager]];
|
|
|
}
|
|
|
@@ -99,9 +102,7 @@
|
|
|
#pragma mark - HJWelcomeViewDelegate
|
|
|
|
|
|
- (void)skipWelcomeView:(HJWelcomeViewController *)welcomeView {
|
|
|
- UIViewController *vc = [self setupFirstViewController];
|
|
|
- vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
|
|
|
- [welcomeView presentViewController:vc animated:YES completion:nil];
|
|
|
+ self.window.rootViewController = [self setupFirstViewController];
|
|
|
}
|
|
|
|
|
|
#pragma mark - event response
|
|
|
@@ -115,58 +116,38 @@
|
|
|
- (UIViewController *)setupFirstViewController {
|
|
|
NSString *userID = [HJUserInfoModel userInfo].userID;
|
|
|
if (userID != nil && ![userID isEqualToString:@""]) {
|
|
|
- return self.mainViewController;
|
|
|
+ HJMainViewController *mainViewController = [[HJMainViewController alloc] init];
|
|
|
+ return mainViewController;
|
|
|
} else {
|
|
|
- UINavigationController *loginNav = [[UINavigationController alloc] initWithRootViewController:self.loginViewController];
|
|
|
+ HJLoginViewController *loginViewController = [[HJLoginViewController alloc] init];
|
|
|
+ UINavigationController *loginNav = [[UINavigationController alloc] initWithRootViewController:loginViewController];
|
|
|
return loginNav;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#pragma mark - getters and setters
|
|
|
-
|
|
|
-- (HJWelcomeViewController *)welcomeViewController {
|
|
|
- if (_welcomeViewController == nil) {
|
|
|
- _welcomeViewController = [[HJWelcomeViewController alloc] init];
|
|
|
- _welcomeViewController.delegate = self;
|
|
|
- }
|
|
|
- return _welcomeViewController;
|
|
|
-}
|
|
|
-
|
|
|
-- (UILabel *)launchVersionLabel {
|
|
|
- if (_launchVersionLabel == nil) {
|
|
|
- _launchVersionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (SCREEN_HEIGHT-45), SCREEN_WIDTH, 20)];
|
|
|
- _launchVersionLabel.text = [NSString stringWithFormat:@"v%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
|
|
|
- _launchVersionLabel.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
|
|
|
- _launchVersionLabel.font = [UIFont systemFontOfSize:11];
|
|
|
- _launchVersionLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
- }
|
|
|
- return _launchVersionLabel;
|
|
|
-}
|
|
|
-
|
|
|
-- (UIButton *)launchStartButton {
|
|
|
- if (_launchStartButton == nil) {
|
|
|
- CGFloat width = HJHorizontalScale(180);
|
|
|
- CGFloat height = 42;
|
|
|
- _launchStartButton = [UIButton hj_createGradientButtonWithTitle:@"开启加薪之旅"];
|
|
|
- _launchStartButton.titleLabel.font = [UIFont systemFontOfSize:HJHorizontalScale(16)];
|
|
|
- _launchStartButton.frame = CGRectMake((SCREEN_WIDTH-width)/2, (SCREEN_HEIGHT-height-90), width, height);
|
|
|
- [_launchStartButton addTarget:self action:@selector(launchStartButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
- }
|
|
|
- return _launchStartButton;
|
|
|
-}
|
|
|
-
|
|
|
-- (HJLoginViewController *)loginViewController {
|
|
|
- if (_loginViewController == nil) {
|
|
|
- _loginViewController = [[HJLoginViewController alloc] init];
|
|
|
- }
|
|
|
- return _loginViewController;
|
|
|
-}
|
|
|
-
|
|
|
-- (HJMainViewController *)mainViewController {
|
|
|
- if (_mainViewController == nil) {
|
|
|
- _mainViewController = [[HJMainViewController alloc] init];
|
|
|
- }
|
|
|
- return _mainViewController;
|
|
|
+- (void)setupAd {
|
|
|
+ //设置你工程的启动页使用的是:LaunchImage 还是 LaunchScreen.storyboard(不设置默认:LaunchImage)
|
|
|
+ [XHLaunchAd setLaunchSourceType:SourceTypeLaunchScreen];
|
|
|
+
|
|
|
+ CGFloat width = HJHorizontalScale(180);
|
|
|
+ CGFloat height = 42;
|
|
|
+ UIButton *launchStartButton = [UIButton hj_createGradientButtonWithTitle:@"开启加薪之旅"];
|
|
|
+ launchStartButton.titleLabel.font = [UIFont systemFontOfSize:HJHorizontalScale(16)];
|
|
|
+ launchStartButton.frame = CGRectMake((SCREEN_WIDTH-width)/2, (SCREEN_HEIGHT-height-90), width, height);
|
|
|
+ [launchStartButton addTarget:self action:@selector(launchStartButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+
|
|
|
+ UILabel *launchVersionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, (SCREEN_HEIGHT-45), SCREEN_WIDTH, 20)];
|
|
|
+ launchVersionLabel.text = [NSString stringWithFormat:@"v%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
|
|
|
+ launchVersionLabel.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
|
|
|
+ launchVersionLabel.font = [UIFont systemFontOfSize:11];
|
|
|
+ launchVersionLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
+
|
|
|
+ XHLaunchImageAdConfiguration *imageAdconfiguration = [XHLaunchImageAdConfiguration defaultConfiguration];
|
|
|
+ imageAdconfiguration.duration = 3;
|
|
|
+ imageAdconfiguration.subViews = @[launchVersionLabel, launchStartButton];
|
|
|
+ imageAdconfiguration.skipButtonType = SkipTypeNone;
|
|
|
+ imageAdconfiguration.showFinishAnimate = ShowFinishAnimateLite;
|
|
|
+ [XHLaunchAd imageAdWithImageAdConfiguration:imageAdconfiguration delegate:self];
|
|
|
}
|
|
|
|
|
|
@end
|