我正在使用 UIPageViewController 和其中的多个 uiwebviews,我从之前加载了我的所有 webviews:
- (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;
}
结果如下: