简体   繁体   English

UIWebView错误委托方法与可到达性

[英]UIWebView Error Delegate Method vs Reachability

I'm in the process of submitting my app to the App Store, but I read that I must notify the user if the internet connection is down when my app needs it. 我正在将我的应用提交到App Store,但我读到,如果我的应用需要互联网连接中断,则必须通知用户。 The Apple page mentioned Reachability as well. 苹果页面也提到了可达性。 Currently, though, I'm using the UIWebView delegate method didFailLoadWithError... 不过,目前,我正在使用UIWebView委托方法didFailLoadWithError ...

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{

    UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error Loading" message:[error localizedDescription] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [errorAlert show];

}

...and it's working fine. ...而且工作正常。 My question is, will my app be rejected for not using Reachability to do this, or is it fine doing what I am currently doing? 我的问题是,我的应用程序是否会因为不使用可到达性而被拒绝,还是可以做我目前正在做的事情?

Thanks in advance. 提前致谢。

No, you're perfectly ok using didFailLoadWithError: . 不,使用didFailLoadWithError:完全可以。

Reachability class could be used to check if host is up (or internet connection at all) before even trying to load some page. Reachability类可用于甚至在尝试加载某些页面之前检查主机是否已启动(或根本没有Internet连接)。 But it is not neccessery, as long as you handle the possible errors - which obviously you do. 但这不是必需的,只要您处理可能的错误-显然您会这样做。

EDIT: 编辑:

It is still a good practice to know wheather you will be able to reach a certain host or not. 知道您是否可以与某个主机联系还是一个好习惯。 You could even modify GUI for each case (instead of just reporting an error). 您甚至可以针对每种情况修改GUI(而不仅仅是报告错误)。 But this can always be done in update :) 但这总是可以在更新中完成:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM