ios 初始化期间无法成功更新网络信息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34359304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 08:25:26  来源:igfitidea点击:

Could not successfully update network info during initialization

iosiphoneswiftreachability

提问by lifemoveson

I get the above mentioned issue all the time when I first launch the app in the day. When I first launch the app, I make server calls to get some data and then play animation video. Server calls is in a separate thread than main UI Thread. Is it something to do with Network Reachability or the animation video ? I think the first part is the major issue but cannot recreate this all the time.

当我当天第一次启动应用程序时,我总是遇到上述问题。当我第一次启动应用程序时,我会调用服务器来获取一些数据,然后播放动画视频。服务器调用位于与主 UI 线程不同的线程中。是否与网络可达性或动画视频有关?我认为第一部分是主要问题,但不能一直重现。

Has anyone experienced the issue ?

有没有人遇到过这个问题?

Below is the code when I first launch the app.

下面是我第一次启动应用程序时的代码。

override func viewDidLoad() {
        super.viewDidLoad();


        self.navigationController?.navigationBarHidden = true;
        self.view.backgroundColor = UIColor.whiteColor();
           dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { () -> Void in
            Items.setup(); //AFNetworking call
        };

        animationViewController.delegate = self;
        animationViewController.view.autoresizesSubviews = true;
        animationViewController.view.autoresizingMask = [.FlexibleLeftMargin, .FlexibleRightMargin];
        animationViewController.view.center = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height / 2);

        self.view.addSubview(animationViewController.view);    

    }

回答by Srithar Rajendran

I have resolved this issue in Xcode 9.1 with below steps.

我已经通过以下步骤在 Xcode 9.1 中解决了这个问题。

1.Select Simulator

1.选择模拟器

2.Select Debug from top menu items.

2.从顶部菜单项中选择调试。

3.Select Location from Debug menu list.

3.从调试菜单列表中选择位置。

4.Select Apple location.

4.选择苹果位置。

回答by 1337holiday

Check if you have an exception breakpoint to capture "All Exceptions" in breakpoint navigator. This fixed it for me.

检查您是否有异常断点来捕获断点导航器中的“所有异常”。这为我修好了。

回答by jusynth

Was experiencing this too, fixed it by giving the simulator a default location. It may be a code smell so watch how you handle the new location permissions in iOS11.

也遇到了这个问题,通过给模拟器一个默认位置来修复它。这可能是代码异味,所以请注意您如何处理 iOS11 中的新位置权限。

回答by Q Liu

I had similar problem. Turns out in the App/Capabilities, I have Wireless Accessory Configuration with some red warnings. Click the button automatically solved the problem.

我有类似的问题。结果在应用程序/功能中,我有一些带有红色警告的无线附件配置。点击按钮自动解决问题。

Not sure if it would work for you. I am using Xcode 8.

不确定它是否适合你。我正在使用 Xcode 8。

回答by ron

Issue: same with Xcode 9.0 iOS11. Resolution: new iOS requires you to manually turn on privacy for new deployment apps. Upgrades of the app is not needed. Following these steps: (1) iPhone "Settings" icon: click (2) "Privacy": click (3) "Location Services": click (4) [Your app]: click on your app (5) "While Using the App": click

问题:与 Xcode 9.0 iOS11 相同。解决方案:新 iOS 要求您为新部署应用手动打开隐私。不需要升级应用程序。按照以下步骤操作: (1) iPhone“设置”图标:点击 (2)“隐私”:点击 (3)“定位服务”:点击 (4)【您的应用】:点击您的应用 (5)“While Using the应用程序”:点击

回答by Saranjith

You might have overrided loadView() without calling super method.

您可能在没有调用 super 方法的情况下覆盖了 loadView()。

Change

改变

override func loadView() {

}

To

override func loadView() {
  super.loadView()
}