我正在使用UIPageViewController和其中的多个uiwebviews,我从之前加载了所有的webview:
- (void) createContentPages
{
NSMutableArray *pageStrings = [[NSMutableArray alloc] init];
for (int i = 0; i < chapters.count; i++)
{
NSString *path;
path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@%@",[arrayDeCapitulos objectAtIndex:i],idioma] ofType:@"txt"];
NSString *arbit;
if (path) {
arbit = [[NSString alloc]initWithContentsOfFile:arbitPath encoding:NSUTF8StringEncoding error:nil];
}
NSString *a;
a=@"LTR";
if ([idioma isEqualToString:@"h"]) {
a=@"RTL";
}
int size=[[[NSUserDefaults standardUserDefaults]objectForKey:@"preferredSize"]integerValue];
NSString *contentString=[NSString stringWithFormat:@"<html DIR='%@'><head>"
"<style>"
"*{ padding-bottom:5;font-size:%i;"
" font-family:'SBL Hebrew';max-width: %fpx;}"
"</style>"
"<meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' />"
"</head>"
"<body>"
"%@"
"</BODY> </HTML>",a,size,self.view.bounds.size.width ,arbit];
[pageStrings addObject:contentString];
}
pageContent = [[NSArray alloc] initWithArray:pageStrings];
}
除非有些事情出错,否则一切都很正常......我已经尝试了一切,有人有什么想法吗?
然后在我的其他课程中加载uiwebview
[webView loadHTMLString:dataObject
baseURL:[NSURL URLWithString:@""]];
[webView setScalesPageToFit:NO];
webView.delegate=self;
-(void)webViewDidFinishLoad:(UIWebView *)webview
{
CGSize contentSize = webView.scrollView.contentSize;
CGSize viewSize = self.view.bounds.size;
float rw = viewSize.width / contentSize.width;
webView.scrollView.minimumZoomScale = rw;
webView.scrollView.maximumZoomScale = rw;
webView.scrollView.zoomScale = rw;
}
结果如下:
答案 0 :(得分:0)
我知道它听起来很奇怪,但通过将html的内容移动到div来完成工作。
NSString *contentString=[NSString stringWithFormat:@"<html DIR='%@'><head>"
"<style>"
"*{ padding-bottom:5;font-size:%i;"
" font-family:'SBL Hebrew'}"
"</style>"
"</head>"
"<body>"
"<div>%@</div>"
"</body> </HTML>",a,size,arbit];
答案 1 :(得分:0)
试试这个
NSString *contentString=[NSString stringWithFormat:@"<html DIR='320px'><head>"
"<style>"
"*{ padding-bottom:5;font-size:%i;"
" font-family:'SBL Hebrew'}"
"</style>"
"</head>"
"<body>"
"<div>%@</div>"
"</body> </HTML>",size,arbit];
你可以设置div宽度:320px;和html代码的高度100%。