views:

246

answers:

3

Hi,

I'm having a really confusing problem. I have a UIWebView that is contained within a UIScrollView (I'm using a UIWebView because there are some hard returns that need to be displayed) and to ensure that the app looks "clean" I'm using [UIWebView sizeToFit] after the content of the WebView had loaded.

The problem is that the content is quite large (they are film reviews from a pre-existing website), and after a certain number of pixels (about 512) the WebView just stops drawing. It does, however, correctly adjust the height of the view.

Some Additional Information:

The WebView needs to be of variable size

Even if I set the size manually to be that large, the issue still occurs (not just when I use SizeToFit)

I cannot just use the scrolling ability of the WebView because there is content above and below it that means that it has to be contained within a ScrollView (I would use a label, but there are hard returns in my text)

I don't think there is anything wrong with my HTML, I will post what I have, below:

body { background-color: transparent; margin-left: 5px; margin-right: 5px; font-family: Georgia, sans-serif; font-size: small; } CONTENT GOES HERE GATHERED FROM AN NSSTRING IN AN OBJECT I CREATED

I tested using a standard view (instead of a ScrollView) and this only happens when the WebView's height is greater than 512 pixels. Anything less than that and it renders all content perfectly

Any ideas? Thanks for your help!

A: 

Have you tried implementing the same in the Interface Builder?

From my experience, it seams that you're adding some UIView(UIImageView etc.) to the UIWebView. UIWebView doesn't need too much configuration.

mxg
I built the interface using Interface Builder, and I'm not adding any views to the UIWebView (I'm adding the UIWebView to a UIView, which is in turn a child of a UIScrollView).I've tried everything I can think of to get this to stop happening, and nothing is working. I am at my wits end!
Dwaine Bailey
A: 

I have fixed my own question! The problem was that I was not resizing the UIView that the WebView was a child of, but instead I was just setting the contentSize of the ScrollView that the View was a child of (if that makes sense...)

So if anybody ever has this issue in the future - ensure you are resizing your UIView correctly!

Dwaine Bailey
A: 

Hey, had a similar issue with a UITextView in a UITableView: if the UITextView is larger than 512pixels, the text within the view is not displayed properly until you scroll manually the page (it is actually rendered but in the same color as the view, making it invisible). Setneedsdisplay, reloaddata, scrollto... nothing worked.

Only workaround was actually to set a larger frame for the cell which includes the UITextView, like this:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
{
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];


        CGRect rec = CGRectMake(0, 0, 768, 1024);
        cell.frame = rec;

        txt = [[UITextView alloc] initWithFrame:CGRectMake(15, 85, 615, 200)];
}

Other solutions are welcome...

Linkineo