• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Resizing UIView: Content CALayer doesn't resize
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resizing UIView: Content CALayer doesn't resize


  • Subject: Re: Resizing UIView: Content CALayer doesn't resize
  • From: Fritz Anderson <email@hidden>
  • Date: Mon, 14 Jan 2013 14:17:45 -0600

I'd forgotten that when I created the web view, I set the autoresizing flags so the height and width are flexible. Here is the new windowDidFinishLoad:

- (void) webViewDidFinishLoad: (UIWebView *) webView
{
    CGRect      myFrame = self.frame;
    myFrame.size.height = self.preferredHeight;
    self.frame = myFrame;
}

With this arrangement, the overlay view and its gradient remain shorter than the 149 points returned by .preferred height. The web view is now the same too-short size.

	— F


On 14 Jan 2013, at 1:27 PM, Fritz Anderson <email@hidden> wrote:

> For a kiosk-style iPad app, I have a UIViewController (outer controller) that responds to a button my allocating an overlay view and making it a subview of the outer controller's view. The outer controller sets the overlay's height to 100 as a placeholder.
>
> The overlay view contains a UIWebView. After the overlay is initialized, it loads an HTML string into the web view. Upon webViewDidFinishLoad:, the overlay asks the web view for the height of its contents, and adjusts the heights of the web view, and a gradient layer, and itself to the content height. See the code at the end of this message.
>
> The preferred height is 149.
>
> I've subclassed CALayer and CAGradientLayer so I can break on setBounds: and setFrame:. What I see is that the overlay, its root layer, the web view, and the gradient layer get initial heights of 100, but once webViewDidFinishLoad: is called, the heights are set to 149. Nothing else. -setTransform: is never called on the layers or the view.
>
> I've put colored borders on the root layer, the gradient layer, and the web view's root layer, so I can measure them on the screen. What I'm seeing: The web view is sized as expected (149). The overlay's root and the gradient display at 113 points height. The layers' bounds and frames were not changed from a height of 149.
>
> Note, by the way, that at the end of webViewDidFinishLoad:, the web view's height is reported as 198. Another headache, though the drawn dimension is correct.
>
> This is wrong. Could someone please tell me what my next step should be?
>
> 	— F
>
>
> - (CGFloat) preferredHeight
> {
>    NSString *  answer = [self.webView stringByEvaluatingJavaScriptFromString:
>                          @"document.getElementById(\"content\").offsetHeight;"];
>    return MAX(answer.floatValue, 100.0);
>    //  Returns 149
> }
>
> - (void) webViewDidFinishLoad: (UIWebView *) webView    //  == self.webView
> {
>    CGRect      webViewFrame = self.webView.frame;
>    webViewFrame.size.height = self.preferredHeight;
>    self.webView.frame = webViewFrame;
>
>    CGRect      myFrame = self.frame;
>    myFrame.size = webViewFrame.size;
>    self.frame = myFrame;
>    //  setBounds on the root layer: origin=(x=0, y=0) size=(width=984, height=149)
>
>    self.gradientLayer.frame = self.layer.bounds;
>    //  setBounds on gradient layer = origin=(x=0, y=0) size=(width=984, height=149)
>
>    //  self.layer.frame = origin=(x=20, y=200) size=(width=984, height=149)
>    //  self.gradientLayer.frame = origin=(x=0, y=0) size=(width=984, height=149)
>    //  self.webView.frame = (0 0; 984 198)
>    //  self.frame = origin=(x=20, y=200) size=(width=984, height=149)
> }
>
> //  113, 149
>
>
>
> --
> Fritz Anderson
> Xcode 4 Unleashed: 4.5 supplement for free!
> http://www.informit.com/store/xcode-4-unleashed-9780672333279
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

--
Fritz Anderson
Xcode 4 Unleashed: 4.5 supplement for free!
http://www.informit.com/store/xcode-4-unleashed-9780672333279


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Resizing UIView: Content CALayer doesn't resize
      • From: Fritz Anderson <email@hidden>
References: 
 >Resizing UIView: Content CALayer doesn't resize (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: Could somebody please fix NSTimer?
  • Next by Date: Re: Could somebody please fix NSTimer?
  • Previous by thread: Resizing UIView: Content CALayer doesn't resize
  • Next by thread: Re: Resizing UIView: Content CALayer doesn't resize
  • Index(es):
    • Date
    • Thread