简体   繁体   中英

how can i set background image(texture) for epub reader webview?

i wanna show a texture for my epub reader uiwebview.i done this before but now iam not able to re create that code again.

i know that whatever code we have to add should add it in webviewdidfinishload method

     - (void)webViewDidFinishLoad:(UIWebView *)thewebView{
      if(texture==1) {  
             webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"darkWoodP.png"]];

 }
    .....



    }

but this only working for one single html (chapter)i need it for all html files.epub may contains 5 to 100 html files..pleaes help me

I fixed this issue,

What i done is

First i create a global flag in my tableviewcell flag=1 means woodcolor texture flag=2 means lightcolor texture

in didselectmethode

if (indexpath.row==1) {
    flag=1;
    [self texturemethode];
} else if (indexpath.row==2) {
    flag=2;
    [self texturemethode];
}

inside texturemethode method

-(void)texturemethode {
    if (flag==1) {
        webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"wood.png"]];
    } else if (flag==2) {
        webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"light.png"]];
    }
}

in webviewDidFinishLoad method

am again checking this

if (flag==1) {
    webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"wood.png"]];
} else if (flag==2) {
    webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"light.png"]];
}

now it will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM