如何将文件上传到UIWebview

时间:2013-06-20 10:08:54

标签: iphone ios ipad

你好我有一个在UIWebview上运行的网址,我有一个浏览选项,我可以从中选择照片,pdf等文件。

但是当我运行UIWebview并单击“浏览”按钮时...它会免除

" WebViewTutorial[1173:c07] Unbalanced calls to begin/end appearance transitions for <UIFileUploadFallbackRootViewController: 0x75a7330>."

我不确定会出现什么问题!我该怎么办。

请在下面找到我的代码供您参考:

#import "WebViewController.h"


    @implementation WebViewController

    @synthesize webView;

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
        if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
            // Initialization code
        }
        return self;
    }

    - (void)viewDidLoad {

        NSString *urlAddress = @"http://html5basicuploader.agnozine.com";

        //Create a URL object.
        NSURL *url = [NSURL URLWithString:urlAddress];

        //URL Requst Object
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

        //Load the request in the UIWebView.
        webView.scrollView.scrollEnabled = NO;
        webView.scrollView.bounces = NO;
        [webView loadRequest:requestObj];

                webView.delegate = self;


    }


    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }


    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
        // Release anything that's not essential, such as cached data
    }

    - (void)webViewDidFinishLoad:(UIWebView *)webView1{

        if([[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad )
        {


            [webView1 stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 3.2;"];
            NSString* javascript = [NSString stringWithFormat:@"window.scrollBy(30, 0);"];
            [webView1 stringByEvaluatingJavaScriptFromString:javascript];
            webView.scalesPageToFit=NO;}
        else if ([[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPhone){

            [webView1 stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 1.2;"];
            NSString* javascript = [NSString stringWithFormat:@"window.scrollBy(0, 0);"];
            [webView1 stringByEvaluatingJavaScriptFromString:javascript];
            webView.scalesPageToFit=NO;}

    }

    - (void)dealloc {
        [webView release];
        [super dealloc];
    }


    @end

提前致谢

0 个答案:

没有答案