I have a UIWebView set to scale to fit in an iPad app that gets its content from and NSString.
If I turn off scale to fit the text is bigger, although would like it to be much bigger, but I lose the zooming feature.
If I set scale to fit on the text is very small as it is obviously scaling the lot to fit the page...and I get zooming back.
How do I get it to allow me to zoom but also decide how large or how small I want the font to be upon firs开发者_C百科t displaying the content?
Thanks
Put this in the CSS of your HTML (or your local .css file), and when loaded on an iPad, the font will be twice the size of the iPhone. I just used it in a project and it worked like a charm.
@media all and (min-device-width: 481px) and (max-device-width: 1024px) {
body { font-size: 200%; }
}
You can also do media queries for portrait / landscape and so on.
NSString *webViewContent = [NSString stringWithFormat:@"<html> \n"
"<head> \n"
"<style type=\"text/css\"> \n"
"body {font-family: \"%@\"; font-size: %@;}\n"
"</style> \n"
"</head> \n"
"<body>%@</body> \n"
"</html>", @"helvetica", [NSNumber numberWithInt:kFieldFontSize], content];
//kFieldFontSize = 'specify your font size'
[yourWebVIew loadHTMLString:webViewContent baseURL:nil];
use the above method to change the font.
精彩评论