• 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: How to detect rotation in progress in viewDidLayoutSubview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to detect rotation in progress in viewDidLayoutSubview


  • Subject: Re: How to detect rotation in progress in viewDidLayoutSubview
  • From: Andreas Falkenhahn <email@hidden>
  • Date: Tue, 29 Nov 2016 20:50:24 +0100

On 29.11.2016 at 17:35 David Duncan wrote:


>> On Nov 29, 2016, at 11:30 AM, Andreas Falkenhahn <email@hidden> wrote:

>> On 28.11.2016 at 16:50 David Duncan wrote:

>>> I think you can do everything you need to do in layoutSubviews
>>> (fundamentally it doesn’t matter if the device rotates or not, you
>>> just want to keep the view centered in its superview).

>> Right, makes sense.

>>> In general you should do as much as possible in layoutSubviews type
>>> methods. However sometimes you really do want to do something
>>> temporary specifically due to a transition between sizes,
>>> orientations, or size classes, and hence why we provide the
>>> “willTransitionTo” methods. If it isn’t a temporary change, then you
>>> don’t want the transition methods, as they are not always called at
>>> points when layoutSubviews will be.

>> Ok, I've now ditched "willTransitionTo" completely and everything is
>> done in my UIView's layoutSubviews method now. Seems to work fine.

>> Just one last thing: the documentation of layoutSubviews mentions
>> that this method, as its name implies, is meant to make adjustments
>> to subviews. But my UIView doesn't have any subviews at all. So
>> currently I'm basically (ab?)using layoutSubviews to make adjustments
>> to the UIView itself, not to its subviews, since there are none.
>> Is that allowed?

> It is generally bad form to modify a view’s own geometry inside of
> layoutSubviews (frame, bounds, center, transform, and a few related
> layer properties), and more generally not outside of initialization
> time. Also keep in mind that when I mentioned layoutSubviews above,
> I also mean the UIViewController methods viewWillLayoutSubviews and
> viewDidLayoutSubviews – and in that case the ‘self’ that you shouldn’t modify is self.view.

> That said, I imagined your view hierarchy was Window =>
> ViewController.View => ContentView, at which point ViewController
> modifying ContentView inside of viewWillLayoutSubviews (for example) is fully kosher.

It is actually just Window => ViewController.View. I really only have
a single UIView initialized by my UIViewController in loadView() and
that's it.

So it's forbidden to move this view in the UIViewController's viewDidLayoutSubviews()
because it is the root view and not a subview? But how should I do it then?

--
Best regards,
 Andreas Falkenhahn                            mailto:email@hidden


_______________________________________________

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: How to detect rotation in progress in viewDidLayoutSubview
      • From: David Duncan <email@hidden>
References: 
 >How to detect rotation in progress in viewDidLayoutSubview (From: Andreas Falkenhahn <email@hidden>)
 >Re: How to detect rotation in progress in viewDidLayoutSubview (From: David Duncan <email@hidden>)
 >Re: How to detect rotation in progress in viewDidLayoutSubview (From: Andreas Falkenhahn <email@hidden>)
 >Re: How to detect rotation in progress in viewDidLayoutSubview (From: David Duncan <email@hidden>)
 >Re: How to detect rotation in progress in viewDidLayoutSubview (From: Andreas Falkenhahn <email@hidden>)
 >Re: How to detect rotation in progress in viewDidLayoutSubview (From: David Duncan <email@hidden>)

  • Prev by Date: Re: Vertically Centered Colon
  • Next by Date: Re: How to detect rotation in progress in viewDidLayoutSubview
  • Previous by thread: Re: How to detect rotation in progress in viewDidLayoutSubview
  • Next by thread: Re: How to detect rotation in progress in viewDidLayoutSubview
  • Index(es):
    • Date
    • Thread