基本上我有一个 web 视图,当单击某些文件扩展名时会打开一个新的视图控制器来查看图像。在 iOS 6 [webView stopLoading] 中,在停止 webview 以传递视图控制器方面非常有效。
由于升级到 iOS 7,这只会工作一次或两次,但随后它将在 webview 中打开所述图像并传递视图控制器。
以下是我之前在 IOS 6 中使用的内容。
任何帮助,将不胜感激。
///////////////
//IMAGE CODE///
///////////////
//Image file links
NSURL *imageURl = [request URL];
NSString *imageFileExtension = [[imageURl absoluteString] pathExtension];
//Image file extensions
NSLog(@"fileExtension is: %@", imageFileExtension);
if ([imageFileExtension hasSuffix:@"png"] || [imageFileExtension hasSuffix:@"jpg"] || [imageFileExtension hasSuffix:@"jpeg"] || [imageFileExtension hasSuffix:@"gif"] || [imageFileExtension hasSuffix:@"bmp"] || [imageFileExtension hasSuffix:@"raw"] || [imageFileExtension hasSuffix:@"PNG"] || [imageFileExtension hasSuffix:@"JPG"] || [imageFileExtension hasSuffix:@"JPEG"] || [imageFileExtension hasSuffix:@"GIF"] || [imageFileExtension hasSuffix:@"BMP"] || [imageFileExtension hasSuffix:@"RAW"]) {
[webView stopLoading];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//Image manager
WebImageViewController * vc = [[WebImageViewController alloc] initWithURL:[request URL]];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
}else{
//Image file links
NSURL *imageURl = [request URL];
NSString *imageFileExtension = [imageURl pathExtension];
//Image file extensions
NSLog(@"fileExtension is: %@", imageFileExtension);
if ([imageFileExtension hasSuffix:@"png"] || [imageFileExtension hasSuffix:@"jpg"] || [imageFileExtension hasSuffix:@"jpeg"] || [imageFileExtension hasSuffix:@"gif"] || [imageFileExtension hasSuffix:@"bmp"] || [imageFileExtension hasSuffix:@"raw"] || [imageFileExtension hasSuffix:@"PNG"] || [imageFileExtension hasSuffix:@"JPG"] || [imageFileExtension hasSuffix:@"JPEG"] || [imageFileExtension hasSuffix:@"GIF"] || [imageFileExtension hasSuffix:@"BMP"] || [imageFileExtension hasSuffix:@"RAW"]) {
[webView stopLoading];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//Image manager
WebImageViewController * vc = [[WebImageViewController alloc] initWithURL:[request URL]];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
}else{
//Image file links
NSURL *imageURl = [request URL];
NSString *imageFileExtension = [imageURl absoluteString];
//Image file extensions
NSLog(@"fileExtension is: %@", imageFileExtension);
if ([imageFileExtension hasSuffix:@"png"] || [imageFileExtension hasSuffix:@"jpg"] || [imageFileExtension hasSuffix:@"jpeg"] || [imageFileExtension hasSuffix:@"gif"] || [imageFileExtension hasSuffix:@"bmp"] || [imageFileExtension hasSuffix:@"raw"] || [imageFileExtension hasSuffix:@"PNG"] || [imageFileExtension hasSuffix:@"JPG"] || [imageFileExtension hasSuffix:@"JPEG"] || [imageFileExtension hasSuffix:@"GIF"] || [imageFileExtension hasSuffix:@"BMP"] || [imageFileExtension hasSuffix:@"RAW"]) {
[webView stopLoading];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//Image manager
WebImageViewController * vc = [[WebImageViewController alloc] initWithURL:[request URL]];
[self.navigationController pushViewController:vc animated:YES];
[vc release];