I want to use TabBar and wnat to also have more than one views.
But then is it possible to have one navigationController for each views?
I want keep track of views in each of them, and ofcourse it should display different navigationBar and views when I tab a new Tabbar item.
Is that possible? I could give it a try but I don't want to waste time. So if it's possiblt, I'm going to start to work.
Thanks to any advice.
Short answer, yes, it's possible. :)
Longer answer: For each of the UIViewControllers, you would instantiate a UINavigationController and set the UIViewController as the root view using initWithRootViewController:. You would then pass these UINavigationControllers into the UITabBarController by setting the viewControllers property.
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.
I have an app planned out that needs to have a custom menu throughout the application. Its not a toolbar or anything like that so i don't think a regular UINavigationController or a UITabBarController will do the job.
What would be the best approach to creating this custom menu that appears in all views? I thought of just creating a view with the custom menu and alloc it for each view but it seems like a bit of an overkill. Extending UINavigationController might also be an option, but I'm not sure.
Would love to hear your opinions.
Thank you! :)
Shai.
The UINavigationController and the UITabBarController are pretty much always the best way to go because they have view and memory management built in. Here's what you can do:
Create a subclass of UITabBarController that hides the tab bar. See the last post on this page: http://www.iphonedevsdk.com/forum/iphone-sdk-development/4091-uitabbarcontroller-hidden-uitabbar.html Make this UITabBarController accessible on a singleton object.
Create a view for your menu and some IBActions corresponding to the menu buttons.
When a menu button is pressed, you can manually switch the tabs of the uitabbarcontroller as follows: tabBarController.selectedIndex = x;
I agree with ade. I think a popover controller added to a shared class would fit best to the iOS style (I'd put it in AppDelegate in order to have reference to it from anywhere and to avoid creating multiple instances and using only one which you will keep displaying / hiding whenever you wish to see the menu)
I can think of two options: 1. Subclass UINavigationController, hide the standard UINavigationBar's view and create your own view and put it on top of it (ugly and who knows what the results will end up like). 2. Add the menu as a subview of UIWindow so it stays on top of everything throughout the app.
I think the best way is to create a custom tool bar and use it across the app. Subclassing UINavBar is another option but not recommended by Apple so I would not go there.
I'd look into using a popover style menu such as WEPopover
I'm writing an iPhone app in Xcode.
I want to create an object of the type UIButton (NewButton) in one viewcontrollers view (viewController1) and than I want to move it to another viewControllers view (viewController2).
Any suggestions on how I do that?
Thanks in advance :)
There are many ways to pass the object which depend on the situation.
The most common ways to do that are either delegates or notifications.
An example of delegates:
http://iosdevelopertips.com/objective-c/the-basics-of-protocols-and-delegates.html
An example of notifications:
http://www.hivestudio.cat/index.php?option=com_content&view=article&id=54:technical-note-communicate-using-nsnotificationcenter&catid=35:technical-note-category&Itemid=76
You might be better off creating 2 separate (but identical looking and/or acting) UIButtons, and put one button in each view, rather than trying to manage safely swapping a button view between 2 different view and controller stacks.
In my app I would like to replace the TabBar with a ToolBar under certain conditions, similar to what happens in the Photos App when a user places it in selections mode (A toolbar with share copy, etc, buttons appear over the tab bar). How can I achieve this please?
This can be achieved by creating a new toolbar, assigning it an appropriate frame and adding it to self.tabBarController.view
I'm assuming your root view controller is a UITabBarController. Sometimes using the canned "Root" UIViewControllers is more of a hindrance than a help, especially if you want a highly custom look that does not fit into the paradigm of what the canned controllers offer. There's no reason you have to use them -- you could write your own, and do your own transition between your sub-UIViewController views onto the screen. You can use the UITabBar without the UITabBarController in your own custom UIViewController subclass, then you don't end up fighting the behavior of UITabBarController. Writing your own root ViewController can be very instructive as well -- you learn about all the things a root ViewController must do to manage the sub-ViewControllers.
I have a UITableViewController that I need to cover with another nib in some situations
Whats a good way to do this?
You might want to check out the class UINavigationController. It helps you manage a stack of view controllers, with only the top one visible.
Depending on what you're attempting to do, you could use presentModalViewController:animated: to slide up a new view and cover your table. Then there is William's solution which would be to create a UINavigationController which will enable you to push and pop views into a stack.