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: Mon, 30 Mar 2015 07:25:57 +0800
- Acceptlanguage: zh-CN
- Thread-topic: setFrame doesn't work if I put the view into UINavigationController?
Yes I am already working on that.
Thanks a lot.
在 2015/3/30 0:20, Kyle Sluder 写道:
On Sun, Mar 29, 2015, at 02:39 AM, GongHao [龚浩] wrote:
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.
Aside from the fact that "drawers" (aka "hamburger basements") are not
native iOS UI, adding a category to UINavigationController is definitely
not the way to achieve this goal. UINavigationController expects to own
its childViewControllers array.
You should investigate custom container view controllers. They are the
officially supported way of compositing multiple view controllers in
your interface.
--Kyle Sluder
在 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