0

1 つは通常のファイルを処理するためのもので、もう 1 つは PDF を処理するためのものです (他の Web ビューの上にオーバーレイとして開きます)。

両方の Web ビューは次のように設定されています。

//Options for webView
webView.delegate = self;
webView.scalesPageToFit = YES;
for (id subview in webView.subviews)
    if ([[subview class] isSubclassOfClass: [UIScrollView class]])
        ((UIScrollView *)subview).bounces = NO;

//Options for pdfViewer
pdfViewer.delegate = self;
pdfViewer.scalesPageToFit = YES;
for (id subview in pdfViewer.subviews)
    if ([[subview class] isSubclassOfClass: [UIScrollView class]])
        ((UIScrollView *)subview).bounces = NO;

この行pdfViewer.delegate = self;により、アプリに問題が発生します。私は使用しているデリゲート メソッドを持っているので、両方のビューをwebViewDidFinishLoadにする必要があります。設定されていない場合、つまりコメントアウトします。PDF がビューに読み込まれますが、期待どおりに起動しません。ただし、行を再度アクティブにすると、PDF はビューにまったく読み込まれません。何らかの衝突が起きているのでしょうか。を複数割り当てることはできますか?delegateselfwebViewDidFinishLoadUIWebViews delegate = self

アップデート:

#import "MyViewController.h"

@implementation MyViewController

@synthesize webView;

//these two just appear to show the page is loading.
@synthesize loadingView;
@synthesize linkLoadView;

//pdfViewer is contained within topView
@synthesize topView;
@synthesize pdfViewer;


- (void)viewDidLoad {
[super viewDidLoad];    

linkLoadView.alpha=0.0;
[topView removeFromSuperview];

//Options for 
webView.delegate = self;
webView.scalesPageToFit = YES;
for (id subview in webView.subviews)
    if ([[subview class] isSubclassOfClass: [UIScrollView class]])
        ((UIScrollView *)subview).bounces = NO;

//Options for 
//pdfViewer.delegate = self;
pdfViewer.scalesPageToFit = YES;
for (id subview in pdfViewer.subviews)
    if ([[subview class] isSubclassOfClass: [UIScrollView class]])
        ((UIScrollView *)subview).bounces = NO;

NSURL *filePath = [NSURL URLWithString:@"*webaddress*/index.html"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:filePath];
[webView loadRequest:requestObj];
}

- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;  {
    /* Add Content Loading Banner */
    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
       [self.view addSubview:linkLoadView];
       linkLoadView.alpha = 1.0;
    }

    /* Handle PDF Opening */
    NSURL *url = [request URL];
    NSString *urlString = [url absoluteString];
    if([urlString rangeOfString:@".pdf"].location == NSNotFound){
        return true;
    } else {
        NSURL *filePath = [NSURL URLWithString:urlString];
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:filePath];
        [pdfViewer loadRequest:requestObj];

        [self.view addSubview:topView];
        [self.view addSubview:linkLoadView];

        return false;
    }

}

- (void) webViewDidFinishLoad:(UIWebView *)theWebView{
    NSLog(@"Fired");    
}

@end
4

1 に答える 1

1

shouldLoadRequest などの UIWebView デリゲートの他のメソッドをオーバーライドしていますか?

複数の webviews への単一のデリゲートを持つことに問題はないので、何かが通常の要求プロセスをどこかで停止していると推測しています。

于 2011-04-06T09:27:58.090 に答える