如何为EPUB阅读器WebView设置背景图(纹理)?

3

我想在我的epub阅读器UIWebView中展示一种纹理。我以前做过这个,但现在无法再次重新创建那段代码。

我知道我们需要添加的任何代码都应该在webviewdidfinishload方法中添加。

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

 }
    .....



    }

但是这仅适用于单个HTML(章节),我需要对所有HTML文件进行操作。EPUB可能包含5到100个HTML文件..请帮帮我。
1个回答

0

我解决了这个问题,

我做的是:

首先,在我的tableviewcell中创建了一个全局标志 flag=1 表示木色纹理 flag=2 表示浅色纹理

在didselectmethode方法中:

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

内部texturemethode方法

-(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"]];
    }
}

在webviewDidFinishLoad方法中,
我再次进行了检查。
if (flag==1) {
    webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"wood.png"]];
} else if (flag==2) {
    webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"light.png"]];
}

现在它会工作了


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接