0

基本的に、特定のファイル拡張子をクリックすると新しいView Controllerが開き、画像が表示されるWebViewがあります。iOS 6 では、[webView stopLoading] は、webview を停止してビュー コントローラーを渡すのに完全に機能しました。

iOS 7 にアップグレードしてから、これは 1 回か 2 回しか機能しませんが、その後、webview で上記の画像を開き、View Controller を渡します。

以下は、以前に 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];
4

1 に答える 1

0

だから私はこれをうまく機能させることができたと思います。いくつかの再コーディングと調整により、私はこれを思いつきました:

        NSURL *imageURl = [request URL];
        NSString *imageFileExtension = [[imageURl absoluteString] pathExtension];

        NSSet *supportedFileExtensions = [NSSet setWithObjects:@"png", @"jpg", @"jpeg", @"gif", @"bmp", @"pdf", @"raw", nil];

        if ([supportedFileExtensions containsObject:[imageFileExtension lowercaseString]]) {

            [webView stopLoading];

            //Image manager
            [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

            WebImageViewController * vc = [[WebImageViewController alloc] initWithURL:[request URL]];
            [self.navigationController pushViewController:vc animated:YES];
            [vc release];
于 2013-09-27T01:27:47.523 に答える