UINavigationController animating view but not header
Is there a way to transition through views in the navigation controller without the header animating?
I'm creating an app which ask开发者_运维问答s users questions, when they click next a new question is pushed onto the NavigationStack and is animated in. But the titlebar is also animated. The title on the title bar does not change so is there a way to stop the title bar from animating?
Thanks
You could use a paged UIScrollView
instead of the UINavigationController
. Setup your view in IB with a UINavigationBar
on top of the view and right below place the UIScrollview
and let the user scroll through your questions this way.
You could stop animation with:
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:NO];
and ensure you set the title for the pushed view controller to the (same) correct title; e.g. in the detailed view controller's viewDidLoad
method do:
self.title = @"title";
Now, you could add a custom initWithTitle:
method say, to you detailed view controller custom class to pass-in the title you require to set if the title need to change, not like you mention in your question.
Hope this helps.
I had the same problem (in my case, I have the same title in every child that I add to the nav controller so animating the title looks funny)
I solved this by adding the title directly the nav controller, and setting the title of child controllers to nil
UINavigationController *nav_controller;
UILabel *lbl_title = [[UILabel alloc] initWithFrame:...]
// Modify your title here
[nav_controller.view addSubview:lbl_title];
UIViewController *vc_child;
vc_child.title = nil;
I dont think there's any straight forward solution to this problem. But i feel it is achievable. You can have one navigation controller. When you push the next view from navigation controller, you may have to take refuge of some custom animations.
What you can do i think is, you can add the next view as subview at a frame where
x = 350( anything beyond the view frame i.e 320, assuming iphone) ,
y = 0 ,
width = 320 and
height = view height - 20 (20 is the height of navigation bar)
you can add your next view as a subview to the existing navigation controller instead of pushing the view from the navigation controller and give some custom animations to the view while changing x values from 350 to 0.
This will seem like you are pushing the view but you are just creating the effect of it by adding as a subview.
Hope this may give an approach towards your solution.
精彩评论