iOS - Customize Navigation Bar for only some UIViewController - ios

I have to add new screens to an existing app, that will use a different navigation bar style than the one that already exists and will be accessed from different screens. The idea would be to show the new Navigation Bar style only for those screens, so when the user finishes that flow or goes back to the screen that started the navigation, it should show again the navigation bar style it was previously using.
I have tried 2 things but didn't work as expected:
I thought of wrapping the new screens in a new UINavigationController, so I could change its navigation bar style and it would be consistent for the new screens. It works but the problem is that I am not able to customize the initial UINavigationController transition to make it not look like a modal (i.e I want to show that UINavigationController with the same animation as if I were pushing a UIViewController). Is there a way to do that? By the way, I am managing the navigations with storyboards segues.
I also thought of using
self.navigationController?.navigationBar.isHidden = true
But doesn't seem clean because I would have to show it again when the flow is finished (it is a bit long) or cancelled. This makes a lot of combinations and it would be easy to miss one of them, so this doesn't seem a practical solution. Is there a better way to do this?

The presenting view controller is where you want to change the nav bar for the controller to be presented. So you'd make any changes to the navbar just before you call push(viewController:animated:).
And then in viewWillAppear of still the presenting view controller you would reset the navbar to what it was initially.
NOTE: Keep in mind that depending on the kind of changes you're doing to the navbar, the transition might no longer be smooth. The user might see some flickering of sorts on the navbar, which would be poor UI/UX.
Edit: Another alternative
Alternatively, you could get rid of the navbar and instead implement your own header view that you can style however you want, to represent the navbar.
You can style it as a simple navbar with a title + back button.
You can style it to look like a navbar with large title
You can style it as a navbar with back button + background image + title + right bar buttons
As you can see, this second alternative offers you more freedom in what you can do.

Related

IOS Custom View or Navigation Bar Controller

I am new to IOS Swift development. I have a navigation bar design which includes, increasing the height (thus increased text size with custom colors), custom UIButton for closing (instead of the usual back button)
and title at the left side (instead of center)
Basically a lot of customization to do. My question is, is it okay to do a custom UIView to act as a navigation bar or should I push through with a NavigationController and just customize it via code?
Thank you.
First of all the navigation bar offer the push navigation through different view controllers in a smarter way, it stacking all the view controllers pushed and it offers some useful features; for example pushing another view controller from storyboard you don't have the need to set the back button and you can come back to the main controller in a simple way.
You can set a custom image for left/right button, set custom fonts and also change the height without big problems; I suggest to keep the navigation bar and evaluate, you should discover in a short time if a nav bar is enough for your needs.

Custom transition between view controllers including navigation bar

I'm following this guide to do a custom transition between two UIViewControllers that are within a navigation controller.
I'm trying to replicate the transition this 'Storehouse' app transition ,see the transition on the far left.
Notice that the transition includes the navigation bar. However, by default the transition only applies to the view UNDER the navigation bar and just crossfades the UINavigation bars between views.
I want a reference to the entire views including the navigation bar so that I can recreate this effect. I understand I'm probably seeing this behavior since they share a UINavigationController, and thus a navigation bar.
Any ideas?
Thanks!
See here
This is a much asked question here on SO btw. Maybe use the search functionality first next time? ;)
EDIT
Reviewing the transition you posted I must say it does not look like this is a UINavigationController setup. The solution I linked above works for a default setup. It looks like 'Storehouse' has put up a custom solution here. (I looks very neat though!).You will probably have to code this by yourself, i.e. fake the navigation bar.

Navigation Bar item Become Title ( while slide, without disappear)

Im sorry if the Title of question isn't 100% correct. To be honest Im not sure how to describe my question. I have problem. I have app which has Navigation Controller (title is called List). In navigation controller I have "Add" item. When I touch the Item, new View Controller is called. When I touch Back button, which is called "List". When I do slide gesture to go back, Button < called "Title" disappear and again appear even if name is same - "Title". I made gif animation to be clear. Does anybody know how to make my app just slide the title without any (dis)appear? Thank you very much and sorry If my english is not best:)
This is the standard UINavigationController behavior and I don't believe you can easily change this. Two options come to mind:
If you really want this feature, the simplest solution is to tell your navigation controller to not show the navigation bar:
Then you can add your own navigation bar to your scenes. You'll have to manually add back buttons that you hook up to IBAction that pops the view controller (or an unwind segue to the previous scene). If your app supports landscape mode, you may also want to tweak the rotation behavior so it's shorter in landscape mode than portrait mode (like the navigation controller does).
By doing this, you still enjoy the navigation controller functionality (pushing and popping), though you're manually adding navigation bars to every scene. The UX isn't going to be identical and you lose interactive pop gesture, too, but it's probably the easiest was to achieve your desired transition animation.
If that's not adequate (e.g. you need interactive gesture for popping, etc.), then you can write this yourself, retiring the navigation controller entirely and then use custom interactive transitions. This was introduced in iOS 7 (see WWDC 2013 video Custom Transitions Using View Controllers) and revised in iOS 8 (see WWDC 2014 video View Controller Advancements in iOS 8).
Frankly, these both feel like heavy-handed solutions (especially the second one), but if you really want to change the animation of the navigation bar associated with the navigation controller, then these are two options. Personally, I'd step back and do a cost-benefit analysis of this endeavor and decide whether this is worth it for a fairly minor UI issue.

What approach should i use when making tab bar application

I'm started to work at new place as iOS programmer. I joined existing project and got an assignment that i don't really know how to approach.
So my problem is this: when you press a button, next window has to have a tab bar with four icons, this means four different navigation stacks. Its not that hard to make, but in main screen i have more then four icons, and if i press any one of them next window always has to have a tab bar with four static icons, like shortcuts or something.
So what should I do? Does anyone had the same situation? I want to start with a good advice to save trouble later on.
You should probably rethink the app design. Tapping an item on the tab bar shouldn't result in a different number of tab bar items, as it leads to an unstable and unpredictable UI.
While not the most efficient in terms of visible content, you could introduce a segmented control (or a similar custom view) on top right under the navigation bar (if there is one), as seen in the Facebook app (though here it is used to perform actions, not changing views).
Your root view controller should be embedded in a navigation controller. Then push a view controller which contains any number of tab bar items not TabBarController. Then you can present each view controller either push or custom.

Tabbar not showing in ios application

i am making one iOS tabbar application in that i have put 4 different tabs and whenever i click on 1 st tab and load another view after clicking of the first tab. After that when i press back button then tabbar is not displaying .So that i want hint that how can i show that
back the tabbar when we move from one tab from another and yes how i can use consistent the tabbar in whole application can you just guys help me on this i am new to iOS development.
here i am put the screen shot ...
here first screen is this one..
when i tap the video button that are first in the view then another window open
which are as under and see the tabbar is not there...
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Looking at your screen snapshots, do I correctly assume you're attempting to transition to the "Videos" scene by touching the big "Videos" button in the center of the "Home" scene (rather than touching the tab bar button at the bottom of the screen, which I assume works fine)? If that's the case, you need to have your button tell the view controller's tab bar controller that you want to change the index of the tab bar, and it takes care of it for you. You cannot do the transition using a segue (or at least not without a custom segue, which is even more complicated than the procedure I outline below). If you're changing the view some other way (e.g. using a standard segue or using presentViewController, pushViewController programmatically, etc.), your tab bar can disappear on you.
You later said:
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Yes, that's true. You cannot use a segue from one of your big buttons to one of the tabs in your tab bar. (Or technically, if you wanted to use a segue, it would be a custom segue which would do something very much like my below code, though perhaps a tad more complicated.) So, rather than using a segue for your big button, you need to write an IBAction (connected to the big Videos button on the Home scene), that tells the tab bar to change its selection:
- (IBAction)clickedVideosButton:(id)sender
{
[self.tabBarController setSelectedIndex:1];
}
A couple of comments:
My answer was predicated on the assumption that your tab bar works as expected when you tap on the buttons of the tab bar, itself. If you tap the buttons at the bottom of the screen, do you transition to your other views correctly and preserve the tab bar? If so, my answer above should solve your issues in getting the big buttons to work. If not, though, then the problem rests elsewhere and you need to show us your code that might account for that (either you're something non-standard in the UITabBarControllerDelegate methods, or your viewDidLoad of the view is doing something nonstandard).
If I understand your user interface design right, you have the tab bar at the bottom as well as the big buttons in the middle, which presumably do the same thing. That is, no offense, a curious user interface design (duplicative buttons, requiring extra tap on a button, etc.). You might want to choose to either use either big buttons (in which you can retire the tab bar, eliminate the IBAction code I've provided above, and just use a nice simple navigation controller and push segues, for example), or just use the tab bar (and lose the home screen, lose the big buttons, etc.).
You also made reference to "press back button", and I don't see any "back" button on any of your screen snapshots. Do I infer that you have a navigation controller and you're doing a pushViewController or push segue somewhere? If you're doing something with back buttons, you might need to clarify your question further.

Resources