Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Created May 16, 2012 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choonkeat/d6589584944685909ae5 to your computer and use it in GitHub Desktop.
Save choonkeat/d6589584944685909ae5 to your computer and use it in GitHub Desktop.
html>body.pphone { font-size:12px; width: 980px; }
html>body.lphone { font-size:18px; width: 1470px; }
html>body.ppad { font-size:12px; width: 768px; }
html>body.lpad { font-size:15.99999996px; width: 1024px; }
<meta name="viewport" content="width=VIEWPORTWIDTH,maximum-scale=4.5;" id="viewport">
NSArray *parts = [htmlstring componentsSeparatedByString:@"VIEWPORTWIDTH"]
NSString *html = [parts componentsJoinedByString:((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? @"768" : @"980")];
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortraitUpsideDown:
case UIInterfaceOrientationPortrait:
if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)) {
[webview stringByEvaluatingJavaScriptFromString:@"document.body.className = 'ppad'"];
} else {
[webview stringByEvaluatingJavaScriptFromString:@"document.body.className = 'pphone'"];
}
break;
default:
if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)) {
[webview stringByEvaluatingJavaScriptFromString:@"document.body.className = 'lpad'"];
} else {
[webview stringByEvaluatingJavaScriptFromString:@"document.body.className = 'lphone'"];
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment