Action bar in all uiviewcontrollers in iOS

What's the best approach for creating an action bar (just once) in iOs that keeps its position / size / content across all UIViewControllers? Can I customize the animation of the UIViewController without ?

I have checked if this can be done with UIToolBar or UINavigationController . Am I on the right track?

Thank you in advance

+3


source to share


2 answers


I ended up doing the following:

1 - Created a UIViewController in the bulletin board which contains a UIView designed as an action bar and a container underneath

2 - I built this container to another UIViewController, which in this case will root view controller



3 - In prepareForSegue, I saved the UIViewController instance loaded inside the container

4 - To switch between this UIViewController and the second one:

UIViewController *newController = ...
UIViewController *oldController = ...

[oldController willMoveToParentViewController:nil];
[self addChildViewController:newController]; 

[self transitionFromViewController:oldController 
toViewController:newController 
duration:0.1
options:UIViewAnimationOptionTransitionNone
animations:^(void) {
    oldController.view.frame = CGRectMake(0 - width, 0, width, height);
    newController.view.frame = CGRectMake(0, 0, width, height);
} 
completion:^(BOOL finished){
    [newController didMoveToParentViewController:self];
}

];

      

0


source


Yes, that's the way. Also use a navigation hierarchy which will automatically give you a navigation bar (action bar). On the tab, you will have to create different navigation hierarchies.



+1


source







All Articles