gpt4 book ai didi

ios - 互联网连接不良时viewWillAppear和viewDidAppear之间的延迟

转载 作者:行者123 更新时间:2023-12-01 19:55:26 25 4
gpt4 key购买 nike

我的应用程序有一个问题:当互联网连接不良时,viewWillAppear的结束与viewDidAppear的开始之间会有一个延迟(大约4s)。但是当互联网正常时,问题就不会发生!

-(void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[_btnMenu setBadgeTextColor:[UIColor whiteColor]];
[self updateNotification];
[_btnMenu setBadgeEdgeInsets:UIEdgeInsetsMake(15, 0, 0, 8)];
[_btnMenu setHideWhenZero:YES];
[self setNeedsStatusBarAppearanceUpdate];
}

-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[WSProgressHUD dismiss];
}

- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[super setUpLocalizationString];
willRoute = NO;


}

最佳答案

我敢肯定,您正在阻止主程序执行的主线程上执行了某些操作(例如Internet检查或任何其他网络操作)。做互联网检查后台线程。

Objective-C

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// DO the internet checking or any other network operations here
});

Swift 3.0
DispatchQueue.global(qos: .background).async {
print("This is run on the background queue")
// DO the internet checking or any other network operations here
}

关于ios - 互联网连接不良时viewWillAppear和viewDidAppear之间的延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42946287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com