我想为我的epub阅读器uiwebview.i显示一个纹理,但以前我无法再次创建该代码。
我知道无论我们要添加什么代码,都应该在webviewdidfinishload方法中添加它
- (void)webViewDidFinishLoad:(UIWebView *)thewebView{
if(texture==1) {
webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"darkWoodP.png"]];
}
.....
}
但这仅适用于单个html(章节),我需要所有html文件。epub可能包含5到100个html文件..pleaes帮助我
最佳答案
我已解决此问题,
我所做的是
首先,我在tableviewcell中创建一个全局标志flag=1
表示木纹理flag=2
表示浅色纹理
在didselectmethode中
if (indexpath.row==1) {
flag=1;
[self texturemethode];
} else if (indexpath.row==2) {
flag=2;
[self 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"]];
}
现在它将工作
关于ios - 如何为epub reader Webview设置背景图像(纹理)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16718088/