On 29.11.2016 at 17:35 David Duncan wrote:
>> On Nov 29, 2016, at 11:30 AM, Andreas Falkenhahn <andr...@falkenhahn.com> >> 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:andr...@falkenhahn.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com