Commit baab4431d70d8a58300a13479d722dc73d0b1dfd
1 parent
c7311b07
启动优化
Showing
1 changed file
with
19 additions
and
14 deletions
CNLiveScioLive/AppDelegate.m
| @@ -17,6 +17,8 @@ | @@ -17,6 +17,8 @@ | ||
| 17 | @interface AppDelegate ()<XGPushDelegate> | 17 | @interface AppDelegate ()<XGPushDelegate> |
| 18 | { | 18 | { |
| 19 | UIImageView *imageView; | 19 | UIImageView *imageView; |
| 20 | + NSTimer *connectionTimer; | ||
| 21 | + BOOL done; | ||
| 20 | } | 22 | } |
| 21 | @property (nonatomic, assign) BOOL isPush; //区分普通启动还是推送 | 23 | @property (nonatomic, assign) BOOL isPush; //区分普通启动还是推送 |
| 22 | @property (nonatomic, copy) NSString *type; //区分首页还是直播 还是id | 24 | @property (nonatomic, copy) NSString *type; //区分首页还是直播 还是id |
| @@ -59,16 +61,10 @@ | @@ -59,16 +61,10 @@ | ||
| 59 | 61 | ||
| 60 | [self initializeSDKConfiguration]; | 62 | [self initializeSDKConfiguration]; |
| 61 | [self requestLanchImage]; | 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 | return YES; | 68 | return YES; |
| 73 | } | 69 | } |
| 74 | -(void)addRootViewController | 70 | -(void)addRootViewController |
| @@ -115,9 +111,16 @@ | @@ -115,9 +111,16 @@ | ||
| 115 | [[NSUserDefaults standardUserDefaults] setValue:nil forKey:HOMETITLECOLOR]; | 111 | [[NSUserDefaults standardUserDefaults] setValue:nil forKey:HOMETITLECOLOR]; |
| 116 | } | 112 | } |
| 117 | NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"lanchImage"]; | 113 | NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"lanchImage"]; |
| 118 | - if (data.length<=0) { | 114 | + NSString *errorCode = dic[@"errorCode"]; |
| 119 | [self addRootViewController]; | 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 | NSURLSessionConfiguration *configuration = [ NSURLSessionConfiguration defaultSessionConfiguration ]; | 124 | NSURLSessionConfiguration *configuration = [ NSURLSessionConfiguration defaultSessionConfiguration ]; |
| 122 | AFURLSessionManager *manager = [[ AFURLSessionManager alloc ] initWithSessionConfiguration :configuration]; | 125 | AFURLSessionManager *manager = [[ AFURLSessionManager alloc ] initWithSessionConfiguration :configuration]; |
| 123 | NSURLRequest *request = [ NSURLRequest requestWithURL :url]; | 126 | NSURLRequest *request = [ NSURLRequest requestWithURL :url]; |
| @@ -133,15 +136,17 @@ | @@ -133,15 +136,17 @@ | ||
| 133 | 136 | ||
| 134 | }]; | 137 | }]; |
| 135 | [downloadTask resume ]; | 138 | [downloadTask resume ]; |
| 136 | - | 139 | + }else{ |
| 140 | + self->done = YES; | ||
| 141 | + } | ||
| 137 | } failure:^(NSError *error) { | 142 | } failure:^(NSError *error) { |
| 138 | [self requestLanchImage]; | 143 | [self requestLanchImage]; |
| 139 | }]; | 144 | }]; |
| 145 | + | ||
| 140 | } | 146 | } |
| 141 | -(void)removeImage{ | 147 | -(void)removeImage{ |
| 142 | [imageView removeFromSuperview]; | 148 | [imageView removeFromSuperview]; |
| 143 | imageView = nil; | 149 | imageView = nil; |
| 144 | - [self addRootViewController]; | ||
| 145 | } | 150 | } |
| 146 | //语言 | 151 | //语言 |
| 147 | #pragma mark - 语言 | 152 | #pragma mark - 语言 |