Re: setFrame doesn't work if I put the view into UINavigationController?
Re: setFrame doesn't work if I put the view into UINavigationController?
- Subject: Re: setFrame doesn't work if I put the view into UINavigationController?
- From: GongHao [龚浩] <email@hidden>
- Date: Sun, 29 Mar 2015 16:39:30 +0800
- Acceptlanguage: zh-CN
- Thread-topic: setFrame doesn't work if I put the view into UINavigationController?
I am trying to implement an Android-like drawer by creating a UINavigationController category, and add a method like [UINavigationController setDrawerViewController:]. The Drawer View Controller is actually pushed to screen by [UINavigationController pushViewController:animated:], and then I need to change the Drawer View's frame to Not fullscreen.
Maybe you are right that I shouldn't try to play with Navigation Controller at all.
在 2015/3/29 15:40, Kyle Sluder 写道:
On Sun, Mar 29, 2015, at 01:26 AM, GongHao [龚浩] wrote:
Thanks,
Eventually I got it work by doing it in
navigationController:didShowViewController:animated:
UINavigationController will set the content view controller's view size
in a private method _startTransition:fromViewController:toViewController:
, changing the frame after this call should work.
This is quite hacky though.
And it's also not guaranteed to continue working. UINavigationController
may change your view's frame at any time it wishes—for example, when you
rotate the device.
As I said, a view controller is not in charge of its view's frame. If
you need the content of a view controller's view to be positioned
differently from where the parent view controller decides the view
should be positioned, you need to add that content as a _subview_ of
your VC's view.
What are you actually trying to achieve?
--Kyle Sluder
_______________________________________________
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