UINavigationController going directly to 'next' controller? - iphone

I have a UINavigationController with 3 levels of hierarchy: Menu->Submenu->Details. Menu and Submenu are UITableViews whereas Details is some custom view controller.
I want to add 'previous' and 'next' buttons in the Details view that will allow me to directly go to the previous and next items from the current Submenu.
For example let's say I have:
|Menu |M1 Submenu |SM2 Details
--------------------------------
M1 -> |SM1 |D1
M2 |SM2 -> |D2
M3 |SM3 |D3 // Let's say we are here now
|D4
// ... etc ...
// The arrows represent items the user selected
So let's say the app is currently showing the D3 Details view controller. This means that we are currently in M1->SM2->D3. Now in D3 if the user presses a 'next' button it should show D4. Similarly if s/he presses the 'previous' button it should show D2.
So the 'next' and 'previous' buttons essentially do the same thing as pressing the navigation controller back button and then selecting the next item in the list.
What would be the best way to implement this? Do I have to pop back up to the submenu and then push another Details controller? Do I call the submenu controller directly from the details view controller (if so how)?
Thanks.

There's really no need to call the parent controller. Here's what you can do:
Assuming you keep an array of "detail" items in Submenu Controller, instead of initializing the detail controller with the selected item, initialize it with the array and the selected index.
Then, when the prev/next buttons are pressed, change the selected index and update the view accordingly.

Related

Programmatically hiding a view controller from a tab bar application

I am working on a tab bar application. Is there a way I can programmatically hide one view controller from the scroll down list and from the "edit" list (but still be able to pop it on screen with a certain action, i.e. by calling its tabbarcontroller index)?
The problem is that I have now so many viewcontrollers that completely fill the "edit" screen. So I want to hide some of them and be able to trigger the hidden ones trough some action performed on one of the visible ones.
Thanks

iPhone app: navigate to tab bar scenario

I have an application with a maybe-strange navigation scenario. I'll try to explain:
1) first scene: select an available item from a list
1.1) once selected, you navigate to a tab view allowing you to view/edit the various attributes
2) if the desired item isn't available, you may create a new one (by selecting a "+" bar button) which navigates to an alternate scene
2.1) there may be multiple scenes required to create the item, all scenes are simply pushed on the stack to allow the user to go back, select different options, etc.
2.2) once all scenes have been displayed and all attributes have been collected, the new "item" will be created and saved.
2.3) now, I want to automatically act as though the user selected this item from the beginning, that is, I want to pop all previous views off the stack and navigate directly into the tabs (step 1.1).
Does this make sense? Easy to do? Is there a better way to go about this? I'm using xCode 4.2 with storyboards.
Any guidance would be appreciated.
If you want (+) button on TabBar you should subclass UITabBar: Fo ex. TabBarPlus and set this class in storyboard.
But easier place (+) button on navigation bar.
The max number of displaying tabsart is 5 for iphone and 8 for ipad. If the there > number of tabs the last is "More" tab thet displaing list of other tubs in tableview. I you want displaying more tabs on tabbar then you should subclass UITabBar :)
If you want by back button on naigation bar switching beetwing Views that references with TabBar buttons you must create stack in code and hide backbutton of navigationbar and use castom left button of navigationbar.
The other navigation can be easy done in storyboard

NavigationBar Right Button Problem

I have a navigation bar in my app. The below pictures are in the order of navigation.
Problem I have is, on clicking the "Main" button , I am able to perform the action and goto the required screen , but the navigation bar does not look like the first on (with Menu as left button). Instead it look like 4th image. How to make it look like first image so that I can make the user to navigate to "Menu" screen by clicking menu button ?. Thanks for the help …!!!
If I'm understanding this correctly, you may have pushed the first view controller (The one from screenshot 1) when clicking on main which is why you see "lens" in the back button. That back button takes the title of the previous view controller in the stack. What you want to do is pop to the first view controller when they click on Main using either popToRootViewController or popToViewController:animated

How do I reset UIScrollView to Zeroth Page/Index when Clicking on a Tab Bar Item?

I have a tab bar application with 3 tabs. The first tab loads a UIImageView that is nested within a paginated ScrollView. If the user were to scroll through the pages for a bit, then click on another tab, and then click back to the first tab, they would return to the last page they scrolled to within the ScrollView.
How can I have make my first tab bar item resets to the initial image/page in my UIImageView every time it's clicked?
Thanks!
Have a look at :
UITabBarControllerDelegate. You have a callback didSelectViewController.
One solution would be for your ApplicationDelegate to get this callback and inform your firstviewcontroller from the first tab to call a method that would just take the user to the first page.

Slide in the second tab bar view by clicking on item in the first

I have an app with three tabs that switch views instantaneously when the user taps them. The first view is a table view selecting which 'location type' to filter by, to only show those pins (add those annotations) to the second view, a MapView.
When a table cell is clicked, it switches instantaneously to the mapview, using this code:
self.tabBarController.selectedIndex=1;
However, I would like to do this with a slide-in-from-right animation, like the one you get when drilling down a hierarchy of table views.
I tried this:
[self.navigationController pushViewController:[self.tabBarController.viewControllers objectAtIndex:1] animated:YES];
which compiles without error or warning, but does not switch views.
How do I 'apply' a navigation controller 'onto' a tab bar controller? Or is there some way to select another viewcontroller and specify an animation?
I don't think you are going to be able to do that with a tab bar controller as there is no API to manage the animations. Your choices are either to swap out the tab bar and build something similar using buttons, in which case you can manage your own view stack, or to forgoe the animation and just switch views as you are doing.
An alternative approach is to display the map as part of the nav-controller stack belonging to your current tab - (assuming you have a nav controller stack) but that's not acutually going to swap tabs for you, just move you to a new place on your current stack.