【发布时间】:2014-07-09 16:55:40
【问题描述】:
嘿,所以我正在手机上运行 iOS8 测试版,但自从我上次更新手机后,我遇到了一些问题,即我的 UIAlertViews 没有在应该出现的时候出现。我绝对没有更改这些部分中的代码,并且它们之前运行良好。 这是相关的代码。简而言之,它会加载一个 webview,当没有互联网连接时,它应该显示没有连接的警报。
- (void)viewDidLoad
{
[super viewDidLoad];
[[self view] setBackgroundColor:[UIColor colorWithRed:1.0f green:0.96f blue:0.33f alpha:1.0]];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.sheffski.co.uk/forum/"]]];
[webView addSubview:activityInd];
timer=[NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES];
}
-(void)loading{
if(!webView.loading)
[activityInd stopAnimating];
else
[activityInd startAnimating];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//No Internet Connection error code
-(void)webView:(UIWebView *)WebView didFailLoadWithError:(NSError *)error {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"You have no internet connection! Reload the app with a connection or try another page." delegate:self cancelButtonTitle:@"Close App" otherButtonTitles:@"Continue", nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if(buttonIndex == 0){
exit(0);
}
}
不幸的是,我无法在 iOS7.1 上对其进行测试,因为我发现 Xcode5 偶尔会觉得我的代码不公平,现在说我与 MediaPlayer 框架有关,所以我只能在 Xcode6 测试版中运行(现在下载 7.1 模拟器)。我想知道是否有人可以看到代码本身有任何问题,以及其他人是否有这个问题!
【问题讨论】:
标签: objective-c uiwebview uialertview ios8 internet-connection