فهرست منبع

登录注册页面全屏

Steven 5 سال پیش
والد
کامیت
c7ce77c767

+ 8 - 8
MusicGradeExam/MusicGradeExam/KSRequestManager.m

@@ -92,14 +92,14 @@
             return ;
         } failBlock:^(NSError * _Nonnull error) {
             NSLog(@"%@",error.description);
-
-                       if (error.code == -1001) {
-                           [self showMessage:@"网络请求超时"];
-                       }
-                       else if (error.code != -999) {
-                           [self showMessage:@"网络或服务器错误,请重试"];
-                       }
-                       faliure(error);
+            
+            if (error.code == -1001) {
+                [self showMessage:@"网络请求超时"];
+            }
+            else if (error.code != -999) {
+                [self showMessage:@"网络或服务器错误,请重试"];
+            }
+            faliure(error);
         }];
     }
 }

+ 10 - 3
MusicGradeExam/MusicGradeExam/Tools/NetworkManager/KSNetworking.m

@@ -22,7 +22,7 @@ static NSDictionary     *headers;
 
 static KSNetworkStatus  networkStatus;
 
-static NSTimeInterval   requestTimeout = 30.0f;  // 超时时间
+static NSTimeInterval   requestTimeout = 20.0f;  // 超时时间
 
 @interface KSNetworking ()
 
@@ -238,10 +238,13 @@ static NSTimeInterval   requestTimeout = 30.0f;  // 超时时间
     __block KSURLSessionTask *session = nil;
        
        AFHTTPSessionManager *manager = [self manager];
+        manager.requestSerializer.timeoutInterval = 300;
+
        if (networkStatus == KSNetworkStatusNotReachable) {
            if (failBlock) failBlock(YQ_ERROR);
            return session;
        }
+        __weak typeof(manager) weakManager = manager;
        session = [manager POST:url parameters:parameters headers:headers constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
            NSString *fileName = nil;
            
@@ -261,11 +264,11 @@ static NSTimeInterval   requestTimeout = 30.0f;  // 超时时间
        } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            if (successBlock) successBlock(responseObject);
            [[KSNetworking allTasks] removeObject:session];
-           
+           weakManager.requestSerializer.timeoutInterval = requestTimeout;
        } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
            if (failBlock) failBlock(error);
            [[KSNetworking allTasks] removeObject:session];
-           
+           weakManager.requestSerializer.timeoutInterval = requestTimeout;
        }];
        [session resume];
        
@@ -380,8 +383,10 @@ static NSTimeInterval   requestTimeout = 30.0f;  // 超时时间
     }
     
     AFHTTPSessionManager *manager = [self manager];
+    manager.requestSerializer.timeoutInterval = 300;
     //响应内容序列化为二进制
     manager.responseSerializer = [AFHTTPResponseSerializer serializer];
+    __weak typeof(manager) weakManager = manager;
     [manager GET:url parameters:nil headers:headers progress:^(NSProgress * _Nonnull downloadProgress) {
         if (progressBlock) progressBlock(downloadProgress.completedUnitCount, downloadProgress.totalUnitCount);
         
@@ -394,12 +399,14 @@ static NSTimeInterval   requestTimeout = 30.0f;  // 超时时间
             NSURL *downFileUrl = [[KSCacheManager shareManager] getDownloadDataFromCacheWithRequestUrl:url];
             
             successBlock(downFileUrl);
+            weakManager.requestSerializer.timeoutInterval = requestTimeout;
         }
         
     } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
         if (failBlock) {
             failBlock (error);
         }
+        weakManager.requestSerializer.timeoutInterval = requestTimeout;
     }];
     [session resume];
     

+ 2 - 1
MusicGradeExam/MusicGradeExam/UI/Login/Controller/LoginViewController.m

@@ -51,13 +51,14 @@
         _bodyView.passwordField.text = UserDefault(PASSWORDKEY);
     }
     _bodyView.isShowBackButton = self.showBackButton;
-    CGFloat height = kScreenHeight - bottomMarginToBottom() > 520 ? kScreenHeight - bottomMarginToBottom() : 520;
+    CGFloat height = kScreenHeight > 520 ? kScreenHeight : 520;
     _bodyView.frame = CGRectMake(0, 0, kScreenWidth, height);
     MJWeakSelf;
     [_bodyView loginActionCallback:^(LOGIN_ACTION action, NSDictionary *parm) {
         [weakSelf operationWithType:action parm:parm];
     }];
     [self.scrollView addSubview:_bodyView];
+    self.scrollView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
     self.scrollView.contentSize = CGSizeMake(kScreenWidth, height);
     self.scrollView.scrollEnabled = NO;
     if (@available(iOS 11.0, *)) {

+ 2 - 2
MusicGradeExam/MusicGradeExam/UI/Login/Controller/RegisterViewController.m

@@ -42,14 +42,14 @@
 
 - (void)configUI {
     _bodyView = [RegisterBodyView shareInstance];
-    CGFloat height = kScreenHeight - bottomMarginToBottom() > 520 ? kScreenHeight - bottomMarginToBottom() : 520;
+    CGFloat height = kScreenHeight > 520 ? kScreenHeight : 520;
     _bodyView.frame = CGRectMake(0, 0, kScreenWidth, height);
 
     MJWeakSelf;
     [_bodyView registerCallback:^(REGISTERACTION action, NSDictionary * _Nonnull parm) {
         [weakSelf operationWithType:action parm:parm];
     }];
-
+    self.scrollView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
     [self.scrollView addSubview:_bodyView];
     self.scrollView.contentSize = CGSizeMake(kScreenWidth, height);
     if (@available(iOS 11.0, *)) {

+ 4 - 2
MusicGradeExam/MusicGradeExam/UI/Login/Controller/VefiLoginViewController.m

@@ -46,14 +46,16 @@
 
 - (void)configUI {
     _bodyView = [VefiBodyView shareInstance];
-    CGFloat height = kScreenHeight - bottomMarginToBottom() > 520 ? kScreenHeight - bottomMarginToBottom() : 520;
+    CGFloat height = kScreenHeight > 520 ? kScreenHeight : 520;
     _bodyView.frame = CGRectMake(0, 0, kScreenWidth, height);
     if (![NSString isEmptyString:self.phoneNo]) {
         _bodyView.phoneField.text = self.phoneNo;
     }
     MJWeakSelf;
     [_bodyView vefiLoginCallback:^(VEFIACTION action, NSDictionary *parm) {
-        [weakSelf operationWithType:action parm:parm];     }];
+        [weakSelf operationWithType:action parm:parm];
+    }];
+    self.scrollView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
     [self.scrollView addSubview:_bodyView];
     self.scrollView.contentSize = CGSizeMake(kScreenWidth, height);
     if (@available(iOS 11.0, *)) {