我在 GatewayManager.m
中实现了这一点+ (void)GetAPIName:(NSString *)APIName
withParameter:(NSMutableDictionary *)parameter
returnManager:(void(^)(AFHTTPSessionManager *manager))returnManager
progress:(void(^)(NSProgress *uploadProgress))progress
success:(void(^)(NSDictionary *result))success
error:(void(^)(NSError *error))failure {
if([ShareFunction isInternetConnecting] && [ShareFunction isVPNConnected]) {
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSString *urlString = [NSString stringWithFormat:@"%@%@", kServerDomain, APIName];
if (![APIName isEqualToString:kAccountLogin]) {
[parameter setObject:[UserManager shareInstance].token forKey:@"accessToken"];
}
[manager GET:urlString
parameters:parameter
progress:^(NSProgress * _Nonnull downloadProgress) {
progress(downloadProgress);
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"[API] %@ Success : %@",APIName, responseObject);
success(responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"[API] %@ Error : %@",APIName, error);
failure(error);
//NSLog(@"[API] %@ Error : %@",APIName, error);
}];
} else {
[ShareFunction showSimpleAlertWithString:@"Internet/VPN no connect" inVC:[UIApplication sharedApplication].keyWindow.rootViewController];
failure(nil);
}
}
我的这行
有问题[ShareFunction showSimpleAlertWithString:@"Internet/VPN no connect" inVC:[UIApplication sharedApplication].keyWindow.rootViewController];
如果是调用此方法的根VC,则在该VC上显示警报消息没有问题。 但如果它不是root VC,我怎样才能在该VC上显示警告消息?
答案 0 :(得分:0)
只需替换此
[ShareFunction showSimpleAlertWithString:@"Internet/VPN no connect" inVC:[UIApplication sharedApplication].keyWindow.rootViewController];
与
[ShareFunction showSimpleAlertWithString:@"Internet/VPN no connect"];