• 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: Problem with setNeedsLayout and layoutSubviews in UIScrollView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with setNeedsLayout and layoutSubviews in UIScrollView


  • Subject: Re: Problem with setNeedsLayout and layoutSubviews in UIScrollView
  • From: David Duncan <email@hidden>
  • Date: Mon, 27 Jun 2011 09:56:18 -0700

On Jun 26, 2011, at 12:51 PM, Tales Pinheiro de Andrade wrote:

> Well, I used the macro UIDeviceOrientationIsLandscape, I'm assuming that this is for both sides:
> #define UIDeviceOrientationIsPortrait(orientation)  ((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown)
> #define UIDeviceOrientationIsLandscape(orientation) ((orientation) == UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight)
>
> So the else only occours when the device is in portrait (being normal or upside down), right?

The problem is that a UIDeviceOrientaiton also includes Unknown, FaceUp and FaceDown orientations. Thus !Landscape means Portrait or one of those (ditto for !Portrait). A large portion of the time, your likely holding the device in FaceUp orientation as far as UIDeviceOrientation is concerned, and thus failing your Landscape check.

> So, if scroll view layout during scroll, I cannot do this resizing in layoutSubview, and should do this in shouldAutorotateToInterfaceOrientation method in my controller?

No, you would use -willAnimateAutorotationToInterfaceOrientation:duration: to do your layout. But at a higher level, why layout based on orientation in the first place? Unless you have specific elements that should not appear in one orientation or another (which doesn't seem to be the case from your code) why not just layout based on the size of the containing view? You can locally determine if it is a portrait or landscape view by comparing width & height in many cases.

--
David Duncan

_______________________________________________

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: Problem with setNeedsLayout and layoutSubviews in UIScrollView
      • From: Tales Pinheiro de Andrade <email@hidden>
References: 
 >Problem with setNeedsLayout and layoutSubviews in UIScrollView (From: Tales Pinheiro de Andrade <email@hidden>)
 >Re: Problem with setNeedsLayout and layoutSubviews in UIScrollView (From: David Duncan <email@hidden>)
 >Re: Problem with setNeedsLayout and layoutSubviews in UIScrollView (From: Tales Pinheiro de Andrade <email@hidden>)

  • Prev by Date: Re: -(id)init methods, NSExceptions, and returning nil
  • Next by Date: Re: Caching Streaming video
  • Previous by thread: Re: Problem with setNeedsLayout and layoutSubviews in UIScrollView
  • Next by thread: Re: Problem with setNeedsLayout and layoutSubviews in UIScrollView
  • Index(es):
    • Date
    • Thread