Вопрос

I have a list of news. By clicking in one of the news the user is sent to a detail view. In the detail view the user is able to swipe horizontally to read more news.

My UIPageViewController receives the list of news and the index of the clicked one.

Inside the detail view I have an UIImage, an UILabel and a UIWebView, all inside a UIScrollView.

The height of both the UIScrollView and the UIWebView is calculated with the method webViewDidFinishLoad.

Opening one of the news is ok, but after swiping twice the UIWebView height stops being calculated correctly.

- (void) webViewDidFinishLoad:(UIWebView *)newWebView {
    CGRect frame = newWebView.frame;
    frame.size.height = 1;
    frame.size.width = width;
    newWebView.frame = frame;
    CGSize fittingSize = [newWebView sizeThatFits:CGSizeZero];
    frame.size = fittingSize;
    newWebView.frame = frame;

    self.scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, frame.size.height + y);
    [newWebView setFrame:CGRectMake(x-8, y, width, frame.size.height)];
    [newWebView setContentMode:UIViewContentModeScaleAspectFit];

    [hud hide:YES];
}

This line retuns 10 height (the default).

newWebView.frame = frame;
Это было полезно?

Решение

Moving the UIScrollView creator to viewDidAppear solved it.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top