2011-11-12 50 views
0

我想添加一个改变,如果用户没有连接到互联网,并点击一个web视图链接。可达性Xcode iOS5

-(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]; 
} 

问题就在这里:

虚空( - )给出错误:()无效的参数类型“无效”,以一元表达

+0

这是在一个.c文件或一个.m文件?这是在Objective C @implementation块内吗?以前的所有功能嵌套在文件中是否正确? – hotpaw2

回答

0

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

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

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

0

这是很简单的,你不必须在用户连接到互联网的检查任何天气的委托方法的代码,例如有一个登录页面你和用户登录,但网络不connectd,所以我们必须给予警告用户,网络是不是connectd吧?只是简单地将

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]; 

}否则你的代码