Commit baab4431d70d8a58300a13479d722dc73d0b1dfd

Authored by yanglingyu
1 parent c7311b07

启动优化

Showing 1 changed file with 19 additions and 14 deletions
CNLiveScioLive/AppDelegate.m
... ... @@ -17,6 +17,8 @@
17 17 @interface AppDelegate ()<XGPushDelegate>
18 18 {
19 19 UIImageView *imageView;
  20 + NSTimer *connectionTimer;
  21 + BOOL done;
20 22 }
21 23 @property (nonatomic, assign) BOOL isPush; //区分普通启动还是推送
22 24 @property (nonatomic, copy) NSString *type; //区分首页还是直播 还是id
... ... @@ -59,16 +61,10 @@
59 61  
60 62 [self initializeSDKConfiguration];
61 63 [self requestLanchImage];
62   - NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"lanchImage"];
63   - if (data.length>0) {
64   - UIViewController *VC = [[UIViewController alloc] init];
65   - imageView= [[UIImageView alloc ] initWithFrame :[ UIScreen mainScreen ]. bounds ];
66   - [imageView setImage:[UIImage imageWithData:data]];
67   - [VC.view addSubview:imageView];
68   - self.window.rootViewController = VC;
69   - [self performSelector:@selector(removeImage) withObject:nil afterDelay:3];
70   - [self.window makeKeyAndVisible];
71   - }
  64 + do{
  65 + [[NSRunLoop currentRunLoop]runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
  66 +
  67 + }while (!done);
72 68 return YES;
73 69 }
74 70 -(void)addRootViewController
... ... @@ -115,9 +111,16 @@
115 111 [[NSUserDefaults standardUserDefaults] setValue:nil forKey:HOMETITLECOLOR];
116 112 }
117 113 NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"lanchImage"];
118   - if (data.length<=0) {
  114 + NSString *errorCode = dic[@"errorCode"];
119 115 [self addRootViewController];
120   - }
  116 + if (errorCode.intValue == 0) {
  117 + if (data.length>0) {
  118 + self->imageView= [[UIImageView alloc ] initWithFrame :[ UIScreen mainScreen ]. bounds ];
  119 + [self->imageView setImage:[UIImage imageWithData:data]];
  120 + [AppKeyWindow addSubview:self->imageView];
  121 + [self performSelector:@selector(removeImage) withObject:nil afterDelay:3];
  122 + self->done = YES;
  123 + }
121 124 NSURLSessionConfiguration *configuration = [ NSURLSessionConfiguration defaultSessionConfiguration ];
122 125 AFURLSessionManager *manager = [[ AFURLSessionManager alloc ] initWithSessionConfiguration :configuration];
123 126 NSURLRequest *request = [ NSURLRequest requestWithURL :url];
... ... @@ -133,15 +136,17 @@
133 136  
134 137 }];
135 138 [downloadTask resume ];
136   -
  139 + }else{
  140 + self->done = YES;
  141 + }
137 142 } failure:^(NSError *error) {
138 143 [self requestLanchImage];
139 144 }];
  145 +
140 146 }
141 147 -(void)removeImage{
142 148 [imageView removeFromSuperview];
143 149 imageView = nil;
144   - [self addRootViewController];
145 150 }
146 151 //语言
147 152 #pragma mark - 语言
... ...