【问题标题】:Reachability Xcode iOS5可达性 Xcode iOS5
【发布时间】:2011-11-12 16:52:04
【问题描述】:

如果用户未连接到互联网并单击 webview 链接,我想添加更改。

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}

问题就在这里:

Void (-) 给出错误:(!)一元表达式的参数类型“void”无效

【问题讨论】:

  • 这是在 .c 文件还是 .m 文件中?这是在Objective C @implementation 块内吗?之前嵌套在文件中的所有函数都正确吗?

标签: iphone xcode


【解决方案1】:

很可能问题不在于-(void)webView:didFailLoadWithError 方法本身;相反,您似乎以不正确的方式使用它,即在需要一元运算符的表达式中(例如,否定、递增等)。

换句话说,您似乎试图在某处使用该方法的返回值,但该方法没有返回值。

检查你调用-(void)webView:didFailLoadWithError的代码...

【讨论】:

    【解决方案2】:

    这很简单,您不必在任何委托方法中编写代码来检查用户是否连接到互联网,例如,您有一个登录页面,用户登录但网络未连接,所以我们有提醒用户网络未连接对吗?只需添加

    if(responce == nil)ie,responce from the url
    {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    

    }否则你编码

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-09
      相关资源
      最近更新 更多