基于内容和uiimageview的动态uiwebview高度大小

时间:2015-01-31 07:05:09

标签: ios objective-c uiwebview uiimageview

我有这样的HTML代码的uiwebview:

NSString *myDescriptionHTML = [NSString stringWithFormat:@"<html  dir=\"rtl\"> \n"
                               "<head> \n"
                               "<style type=\"text/css\"> \n"
                               "body {font-family: \"%@\"; font-size: %@;}\n"
                               "</style> \n"
                               "</head> \n"
                               "<body>%@</body> \n"
                               "</html>", @"B BigFont", [NSNumber numberWithInt:18], self.Bodys];


self.htmlStrings = @[myDescriptionHTML];
for (NSString *html in self.htmlStrings) {
    UIWebView *webView = (UIWebView *)[self.view viewWithTag:3];
    [webView loadHTMLString:html baseURL:nil];
    for (UIView *view in webView.subviews) {
        if ([view isKindOfClass:[UIScrollView class]]) {
            UIScrollView *scrollView = (UIScrollView *)view;
            scrollView.scrollEnabled = YES;

        }
    }

在我的视图和webview中也有Uiimageview:

    [bookpic setImageWithURL:[NSURL URLWithString:self.bookimageUrl]];
    __weak UIImageView *weakImageView = bookpic;
    NSURLRequest *request1 = [NSURLRequest requestWithURL:[NSURL URLWithString:self.bookimageUrl]];
    [bookpic setImageWithURLRequest:request1
                placeholderImage:[UIImage imageNamed:@"loading.png"]
                         success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
                             UIImageView *strongImageView = weakImageView; // make local strong reference to protect against race conditions
                             if (!strongImageView) return;

                             [UIView transitionWithView:strongImageView
                                               duration:0.3
                                                options:UIViewAnimationOptionTransitionCrossDissolve
                                             animations:^{
                                                 strongImageView.image = image;
                                             }
                                             completion:NULL];
                         }
                         failure:NULL];

因为你可以看到我的图像位置是静态的,我的webview内容是可滚动的。

现在我想在我的webview中添加uiimageview并使其可滚动,如

newsrepublic申请。

这是用图像处理webview的方式:

enter image description here

另一个有趣的事情是当你在Newsrepublic应用程序上滚动新闻时

imageview和webview滚动具有不同的滚动速度,最后是文本

在uiimageview上面加上上面的IOS标签消失了。

现在我应该如何实现这一目标?我应该插入我的uiimageview和webview

在uiscrollview中?或者我应该将uiimageview添加到uiwebview并让

webview处理滚动?

0 个答案:

没有答案