cari

Rumah  >  Soal Jawab  >  teks badan

objective-c - iOS UIWebview 加载HTMLString的问题

后台返回的数据是这样的%3Cp%3E%3Cimg+src%3D%22http%3A%2F%2F172.16.129.195%2Fwly-admin%2Fstatic%2Fupload%2Fimage%2Fproductdetail%2F20160514688c38694-d793-4e82-98b2-6aa4b1930f5f-source_7501280.jpg%22+style%3D%22%22%2F%3E%3C%2Fp%3E%3Cp%3E%3Cimg+src%3D%22http%3A%2F%2F172.16.129.195%2Fwly-admin%2Fstatic%2Fupload%2Fimage%2Fproductdetail%2F201605146ad636080-ceb2-459f-b8b0-2f744b59308a-source_7501280.jpg%22+style%3D%22%22%2F%3E%3C%2Fp%3E%3Cp%3E%3Cbr%2F%3E%3C%2Fp%3E
请问我该怎么加载到UIWebview

PHPzPHPz2809 hari yang lalu872

membalas semua(3)saya akan balas

  • 黄舟

    黄舟2017-04-18 09:15:25

     NSString *bacnStr = @"%3Cp%3E%3Cimg+src%3D%22http%3A%2F%2F172.16.129.195%2Fwly-admin%2Fstatic%2Fupload%2Fimage%2Fproductdetail%2F20160514688c38694-d793-4e82-98b2-6aa4b1930f5f-source_7501280.jpg%22+style%3D%22%22%2F%3E%3C%2Fp%3E%3Cp%3E%3Cimg+src%3D%22http%3A%2F%2F172.16.129.195%2Fwly-admin%2Fstatic%2Fupload%2Fimage%2Fproductdetail%2F201605146ad636080-ceb2-459f-b8b0-2f744b59308a-source_7501280.jpg%22+style%3D%22%22%2F%3E%3C%2Fp%3E%3Cp%3E%3Cbr%2F%3E%3C%2Fp%3E";
        
        
        NSLog(@"%@",[bacnStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]);

    Hasil cetakan adalah seperti berikut:

    <p><img+src="http://172.16.129.195/wly-admin/static/upload/image/productdetail/20160514688c38694-d793-4e82-98b2-6aa4b1930f5f-source_7501280.jpg"+style=""/></p><p><img+src="http://172.16.129.195/wly-admin/static/upload/image/productdetail/201605146ad636080-ceb2-459f-b8b0-2f744b59308a-source_7501280.jpg"+style=""/></p><p><br/></p>

    Hanya muatHTMLString selepas membuat paparan web baharu.

     NSString *bacnStr = @"%3Cp%3E%3Cimg+src%3D%22http%3A%2F%2F172.16.129.195%2Fwly-admin%2Fstatic%2Fupload%2Fimage%2Fproductdetail%2F20160514688c38694-d793-4e82-98b2-6aa4b1930f5f-source_7501280.jpg%22+style%3D%22%22%2F%3E%3C%2Fp%3E%3Cp%3E%3Cimg+src%3D%22http%3A%2F%2F172.16.129.195%2Fwly-admin%2Fstatic%2Fupload%2Fimage%2Fproductdetail%2F201605146ad636080-ceb2-459f-b8b0-2f744b59308a-source_7501280.jpg%22+style%3D%22%22%2F%3E%3C%2Fp%3E%3Cp%3E%3Cbr%2F%3E%3C%2Fp%3E";
        
    //解码字符串
        NSString *newBacnStr = [bacnStr stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    
        UIWebView *webview = [[UIWebView alloc]initWithFrame:self.view.frame];
        [webview loadHTMLString:newBacnStr baseURL:nil];
        [self.view addSubview:webview];

    balas
    0
  • 迷茫

    迷茫2017-04-18 09:15:25

    Selepas menyahkod url, terdapat teg html Bolehkah anda cuba menyimpannya sebagai fail HTML dan kemudian memuatkan fail HTML? Atau gunakan rangka kerja Google yang boleh menghuraikan alamat imej dalam teg HTML. Semoga ia dapat memberi anda sedikit idea

    balas
    0
  • 高洛峰

    高洛峰2017-04-18 09:15:25

    Adakah masalah anda telah selesai?

    balas
    0
  • Batalbalas