0
votes

I m working for a project where in a view i had a few labels at the top and a web view in the bottom whose content changes dynamically from the server.I wanted the view to scroll till the web view content which is not happening when auto layout is enabled.

In this way i changed the frame of the Web view

  • (void)webViewDidFinishLoad:(UIWebView *)webView { //giving view default width and event content length as height CGSize myWebViewTextSize = [webView sizeThatFits:CGSizeMake(self.view.frame.size.width,[myCalendarObj.event_content length])];

    CGRect myWebViewFrame = webView.frame; myWebViewFrame.size.height = myWebViewTextSize.height;

    //setting frame size of web view to display dynamic content string webView.frame = myWebViewFrame;

    webView.scrollView.scrollEnabled=NO;

    //setting content size of scrollview equal to web view content to scroll till the end [scrollView setContentSize:CGSizeMake(self.view.frame.size.width,(myWebViewTextSize.height+200))];
    }

This is worked for me when i disabled auto layout but i wanted this when auto layout is enabled.

Please help me on this issue

Thanks in Advance

1
When working with auto layout, you must replace code working with frames and rects with constraints. Auto layout is not concerned with explicit frames, but rather an element's placement in relation to other elements - Marius Waldal

1 Answers

0
votes

If you use xcode5, you should choose from "Editor -> Resolve Auto Layout Issues -> Add Missing Constraints" to add contraints after you've enabled auto layout. While for xcode4, after you've chosen auto layout, the constraints will be added automatically.