背景图片和UIWebView

时间:2012-03-08 18:51:11

标签: ios5 uiwebview uiscrollview uiimage

我能够通过TableView DetailView添加背景图像,但我的解决方案肯定是不正确的。我有一个包含UIWebView的UIScrollView。当我触摸并拖动UIWebView时,我可以在UIScrollView上看到下面的背景图像。除此之外它看起来很棒。

我该怎么办?

以下是执行视图的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{   

    //...


 /*#####################################################
 *
 * Initialize Scroll & HTML View
 *
 #####################################################*/
 CGRect bounds = [ [ UIScreen mainScreen ] applicationFrame ];
 CGRect screenRect = [[UIScreen mainScreen] bounds];
 CGFloat screenWidth = screenRect.size.width;
 CGFloat screenHeight = screenRect.size.height;


 UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:bounds];


htmlView = [ [ UIWebView alloc ] initWithFrame:[scrollView bounds]];
htmlView.frame = CGRectMake(0,0,screenWidth,screenHeight);

htmlView.backgroundColor = [UIColor clearColor];
htmlView.opaque = NO;
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"dark-chalkboard-bg.png"]];
htmlView.backgroundColor = background;


NSString  *htmlString = @"HTML-formatted text goes here";

[htmlView loadHTMLString:htmlString baseURL:nil];

scrollView.contentSize = [htmlView bounds].size;

[scrollView addSubview:htmlView];

//...

}

由于

0 个答案:

没有答案