I've got a UISearchBar in my view, and when the results button is pressed I'd like it to load in a new view. Is this possible without using a navigation controller?
I'm new to iPhone development so not entirely sure if moving between views is solely reliable on a navigation controller or not. From all the examples I've seen using pushViewController, it seems to look that way. Hoping I'm proven wrong.
UINavigationController provides the simplest way to manage a stack of view controllers, but it's not necessary by any means; you can move your views around, and add and remove them from the hierarchy, however you like. Can you elaborate on what you're trying to do, and why you want to avoid using a navigation controller?
Related
I am new in developing iOS apps. I am trying to develop a multiple views app. My doubt is how to manage a multiple views app with View Controller, I mean, I do not want to use Navigation Controller nor Tab Controller.
My idea is to show a first View to choose the language, and after this, I want to show some different profiles in a table view. When you choose the profile, you get into a menu where you have some different functionalities (Once in this menu, I might use Navigation Controller).
My problem is that I don't know how to manage these two first views. I don't know if I have to declare them in the appDelegate, or if I can do it nesting one to other, I mean, I do the first view, and when I pressed the button, I declare the new view. Once in the new view, when I pressed a row in the table view, I make the another view.
I know it is a little bit confusing, so I hope you could understand it quite well.
EDIT:
I want to clarify that I am not using storyboards. My main doubt is what to do with all de view controllers, Do I have to declare all of them in the appDelegate? or Can I declare each view in every controller?
If you are using storyboards, you can use Segue's to navigate between the views, so you would show your first view, then you could tie a button to the next view (by control dragging in storyboard). If you want to transition programmatically you can use the performSegueWithIdentifier method. You could use the same approach to get from your tableViewController to your next viewController by using the performSegueWithIdentifier method from within the tableViewController's didSelectRowAtIndexPath delegate method (i.e. when a user taps a cell).
That should get you started. Good luck!
EDIT:
You really should be using storyboards. It's the way to do things these days. If you refuse, then the best approach is to create a container view controller that manages your "children" view controllers. You can find information on doing this, as well as the methods needed to present/remove child view controllers here:
Custom Container View Controllers
You can use navigation controller with "hidden" property.
self.navController.navigationBarHidden = YES;
If you want to have two different views and transition between them, you will want to use UIViewControllers presented modally. Here is Apple's Guide to this.
My goal is to get a navigation bar like the HBO GO app on iPad. Their nav bar has a larger height and a custom background. It seems like they're using a navigation controller since when you press on a show it takes you to a new screen with a back button.
I'm wondering either
1) Can I use an instance of UINavigationBar without a NavigationController and use the navigation bar delegate to handle pushing and popping my views?
or
2)Is there another way that I can implement this?
I am currently trying to do this with a navigation controller and navigation bar but I am running into difficulties and I think its not the best way to do it. Also Apple docs specifically say not to change the frame of the navigation bar in a navcontroller.
Ideas please? Thanks in advance!
From the looks of it, the HBO Go application uses completely custom navigation controls. A basic UINavigationController-alike class is relatively straightforward to build, but you must be careful to consider that UIViewControllers are not intended to be nested on iOS <= 4 and so you will have to pass through several methods such as view{Will,Did}appear:.
I recommend starting from the ground up, as trying to heavily customize the built-in controls will only lead to further frustrations as you run into issues or limitations in their customizability.
I'm trying to develop an app having a tab bar controller with 5 bar items.
All of the items need navigation controllers.
I just wanted to know whether it is possible to reuse the same navigation controller for all the items.
Are there any restrictions or things I need to keep in mind to do this?
Every tab in a UITabBarController should have its own UINavigationController, if you're in need of one that is. You push and pop UIViewControllers onto/off a stack and every UINavigationController has its own stack. Since the UIViewControllers from your other tabs have nothing to do with the navigation flow from the current tab, each tab should have its own UINavigationController.
I think I may have misinterpreted your question originally here... Navigation Controllers actually fine to re-use I think... I'd recommend release and creating a new on when the tab is changed if that makes sense within the application. You could give a reference to it in your appDelegate so it's easily accessible from each view controller.
Original reply follows in case I'm misinterpreting it still :S
The separation is entirely up to you, but for code clarity it's nice to have each viewcontroller separate. As a lot of the code will be found in your controller it's quite nice to separate out as much as possible. You can use the same controller, but change it's view property when each item is clicked, but it doesn't really save much and wil make for harder to maintain code...
Im a budding iphone developer, and doing my best but i have a query regarding the UINavigationController.
I have a tab bar app, with 3 tabs.
The 1st tab has five UIButtons, each loading a different "section" of the app, and each section will have a number of views.
The other tabs simply display some info.
as users select any of the UIButtons on my first tab i am using [self.view addSubview: xxxxx];
and as users navigate away from this view i use [self.view removeFromSuperview];
My question is:
Is this a bad way to do things? should i use a navigation controller? The reason i have not used one is because i wanted a custom looking UI and i understand that the navigation controller forces your design a little.
And on top of that i will be using core data to implement persistent storage.... will my way of implementing this application cause an issue with core data?
Any help regarding thsi would be highly appreciated.
Cheers
Tom
First, if you don't need a navigation controller, then don't use it. You shouldn't feel bad about it. That said, I think UINavigationController doesn't impose a specific UI on you at all. It's very easy to hide the navigation bar and implement any UI you like. The thing that UINavigationController does impose is a modular design: each view is managed by a separate view controller and takes up the full screen. Only you can answer if this design is suitable for your app. If it is and if your app is designed around a hierarchy of views, a navigation controller is probably a good choice.
As you said: when one of the five buttons is tapped the users is navigating to another view and the five buttons disappear. This is what the navigation controller is designed for and helps you manage the memory better than simply adding and removing views (depending on how many views are added/removed it might also be better on performance). As Ole points out the NavigationController is highly customizable and doesn't impose much.
A NavigationController gives you more flexibility down the road: say you want to add another hierarchy level after one of the buttons has been tapped in version 2.0. Then you will find that your MainView will be growing as you keep adding views to it. A UINavigationController keeps your code well structured and lets you extend the navigation later one.
CoreData is very flexible and UI-independent. You shouldn't have to worry about this.
I've involved myself so much in NavigationControllers that I've become kinda ignorant with other options.
Here's what I want to accomplish, I've built Subclassed ViewControllers to Push via NavigationController that works pretty fine.
However, to avoid the Idea of going back and getting to a new view doesn't fit for quick access since this is about calculator, I came up with using SegmentedControl.
I added UISegmentControl to the NavigationBar.
What I want to accomplish, is on tapping of a segment, The Calculator1ViewController Loads below the NavigationBar. And on tapping another Segment, the previous ViewController is unloaded and a different "Calculator2ViewController" is loaded.
I'm not quite sure how to do it, loadFromNib may not work too well, because I'm using custom ViewControllers.
Any suggestions would be great help.
You might be better off making it a single view controller, and just swapping out the views.