- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- (void) fixUIAfterRotation: (UIInterfaceOrientation) interfaceOrientation
{
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:UIInterfaceOrientationIsPortrait(interfaceOrientation)? @"bg_new.png":@"bg_new_90.png"]]];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString *htmlStr;
webError = NO;
orient = UIInterfaceOrientationIsPortrait(interfaceOrientation)? 1:2;
float width_ = [[UIScreen mainScreen] bounds].size.height;
viewNews.frame = isRotation? (UIInterfaceOrientationIsPortrait(interfaceOrientation)?
CGRectMake(0, 0, width_, 240):CGRectMake(0, 0, width_, width_ - 90)):(UIInterfaceOrientationIsPortrait(interfaceOrientation)? CGRectMake(0, 0, 320, width_ - 81):CGRectMake(0, 0, width_, 240));
isRotation = isRotation? NO:isRotation;
#if defined(PRO_PROJECT)
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
htmlStr = [NSString stringWithFormat:@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled Document</title>
<style>body {margin:0px; padding:0px; font:13px arial; background:none;}
a {text-decoration:underline; color:#fbcf04; font-weight:bold; !important;} a:hover {text-decoration:none;}
.title{background:#575757 left top repeat-x; font:bold 15px Arial; color:#FFF; padding:14px 30px 0px 0px; height:31px;
border-bottom:1px solid #000000; line-height:14px}.titleIm{background:#575757 left top repeat-x; padding:13px 8px 13px 13px; height:31px;
border-bottom:1px solid #000000;}.news_body {border-top:1px solid #414141; padding:10px 14px 14px 14px;
color:#FFF; line-height:19px; background:#3d3d3d;}.news_body p {padding-top:0px;}</style></head>
<body><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"320\" height=\"388\"><tr><td width=\"75\" valign=\"top\" class=\"titleIm\">
<img src=%@ height=\"70\" width=\"70\"></td><td valign=\"top\" class=\"title\">%@
<div style=\"font:11px Arial; color:#858585; line-height:18px;\">%@</div></td></tr><tr>
<td colspan=\"2\" valign=\"top\" class=\"news_body\">%@</td></tr></table></body></html>",
imageName, [newsDescription objectForKey:@"titleNews"],
[CORENewsTitleList getDataString:[newsDescription objectForKey:@"dateNews"]],
[newsDescription objectForKey:@"discriptionNews"]];
}
else
{
htmlStr = [NSString stringWithFormat:@"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">
<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Untitled Document</title>
<style>body {margin:0px; padding:0px; font:13px arial; background:none;}
a {text-decoration:underline; color:#fbcf04; font-weight:bold; !important;}a:hover {text-decoration:none;}
.title {background:#575757 left top repeat-x; font:bold 15px Arial; color:#FFF; padding:14px 30px 0px 0px; height:31px;
border-bottom:1px solid #000000; line-height:14px}.titleIm {background:#575757 left top repeat-x; padding:13px 8px 13px 13px; height:31px;
border-bottom:1px solid #000000;}.news_body {border-top:1px solid #414141; padding:10px 14px 14px 14px;
color:#FFF; line-height:19px; background:#3d3d3d;}.news_body p {padding-top:0px;}</style></head>
<body><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"%f\" height=\"240\"><tr><td width=\"75\" valign=\"top\" class=\"titleIm\">
<img src=%@ height=\"70\" width=\"70\"></td><td valign=\"top\" class=\"title\">%@
<div style=\"font:11px Arial; color:#858585; line-height:18px;\">%@</div></td></tr><tr>
<td colspan=\"2\" valign=\"top\" class=\"news_body\">%@</td></tr></table></body></html>",
width_, imageName, [newsDescription objectForKey:@"titleNews"],
[CORENewsTitleList getDataString:[newsDescription objectForKey:@"dateNews"]],
[newsDescription objectForKey:@"discriptionNews"]];
}
#else
if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
// тот же упоротый код, что и выше, за исключением цветов для бэкграунда и надписей.
}
else
{
// тот же упоротый код, что и выше, за исключением цветов для бэкграунда и надписей.
}
#endif
[viewNews loadHTMLString:htmlStr baseURL:baseURL];
}
Поворачиваем вебвью во вью-контроллере, который может использоваться в 2 проектах, имеющих различные темы (отличается бэкграунд и цвет надписей).