I followed this tutorial from AppCoda to resolve an issue I had with my TabApplication, it is NOT. a webkit, I used this tactic to resolve my tab titles not displaying.
This is an app to list bands for a local event. So You've got:
TabBarController > Nav1 > RELATIONSHIP > Home
> Nav2 > RELATIONSHIP > ARTISTS > UIBUTTON > push to new page.
> etc.
They all work wonderfully; if I click on an artist image (UIButton) it takes me to their page. Top part is a banner (UIIMAGE) and the bottom area is a UISCROLLVIEW.
Here lies my problem: If I CLICK on the Artist Button, scroll the UIScrollView to the bottom, and it I leave the page by hitting another Tab Button I get conflict: When I tap the button to go back to the Artist list (not specified artist) It takes me where I left off and there's an awkward gap between the bottom of the UIScrollView and the Tab Bar with links.
Is there a way I can specify to return to the Artist page with the 6 UIBUTTONS? Or even GET RID of the TabBar options on the bottom part of the screen? I don't know how to code UISCROLLVIEW, I just used Storyboard to draw the ScrollView out because this is one thing I could never work out.
___________________________________
| |
|_________ARTIST____________NAME__|
| |
| :) |
| |
| |
| |
| :) |
|_________________________________|
| |
| |
| .....UISCROLLVIEW |
|_________________________________|
|MAKE_BLANK __BAR_____NO LINKS____| Sorry for the horrible example.
As I understand it your navigation problem is this:
On Tab 2 you have a Navigation Controller whose initial viewController is a list of artists names. If you select an artists name, you segue to a second viewController (still in Tab 2), which shows that artists details.
Now if you navigate to Tab 1, do other stuff, go back to tab 2, you want to ensure you are presented with the initial viewController with the list of artists names, whereas you are being returned to the same artist's page you had left. This leaves your app in a poorly-navigated state (with a glitchy scrollView).
So what you want to do is prevent the user from tabbing away from an artists page, so that they are forced to return to the artists list from where they can tab elsewhere.
You can achieve this by presenting the artists viewController from the initial viewController, rather than pushing onto the navigationController's stack of viewControllers (which I assume you are doing now).
To do this you don't actually use the navigation controller in tab2, so you might choose to get rid of it (unless you want the top navBar for other reasons).
In code
From artistsNamesViewController, make a button with an action:
- (IBAction) presentArtistsDetailViewController:(id)sender
{
ArtistsDetailViewController* artistsDetailViewController = [ArtistsDetailViewController alloc] init];
//set up artistsDetailViewController properties here
[self presentViewController:artistsDetailViewController animated:YES completion:nil];
}
Using storyboard
Instead of code, you can drag a segue line from the button to your artistsDetailViewController, select segue type modal. If you need to initialise properties in your artistsDetailViewController, you can do it in prepareForSegue
You will see that this type of navigation uses a default slide-up animation to show the new viewController, and the entire screen changes - you lose your tab bar. You can change the animation by setting the modalTransitionStyle property on artistsDetailViewController.
Navigation back is controlled by adding a 'dismiss' button, with an IBAction something like this...
- (IBAction) dismiss:(id) sender
{
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]
}
Your user can now only tab away from tab 2 if they are on the initial artistsNamesViewController. You won't get a glitch in your scrollView because every time you go to an artists detail page you are recreating and reinitialising it. This doesn't address other parts of your app where you may be experiencing a problem scrollView (as you suggest in your comment), but that is a separate issue, I wanted to address your navigation logic.
You won't get a navigation bar at the top of your artistsDetailViewController this way, as the navigation controller is not involved. If you want a navigation bar, you can manually place on onto the viewController in the storyboard.
Related
My iPhone app starts off (using a storyboard) with a navigation controller, then a table view controller; what I want to do next is use a tool bar to provide options to go to other table view controllers. The problem is that the tool bar is buried off screen. I would like it to be more like a screen footer, always visible to the user. What is the best way to do this?
The toolbar was originally added to the tableview so as the list got longer the toolbar showed up at the end of the list hidden off the screen unless you scrolled down.
To fix this problem in the Attributes section of the Navigation Controller in the Simulated Metrics I set Bottom Bar to Toolbar. I then did the same thing in the Table View Controller. I then added the Bar Button Items to the toolbar on the Table View Controller.
Then I had to control where the toolbar appeared downstream by calling
- (void)viewWillAppear:(BOOL)animated
{
self.navigationController.toolbarHidden = YES;
}
in the applicable table view controllers and setting YES or NO.
For some reason I was unable to find good documentation for this process. It probably is out there, but I have included it here for others who may have this problem.
I'm really pulling my hair out over this one.
I'm showing an action sheet on the first view controller within my first tab bar item, when I tap OK, I'm switching to another view within another tab bar item, using the following code.
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
self.tabBarController.selectedIndex = 1;
}
(I assign view controllers to a navigation controller, then to a tab within my app delegate, repeating the process for each tab).
On return from second tab, when I tap tab item one the title and info button has gone.
If I go to next view in the navigation stack within the first tab and back, the title returns.
Here's my first view, I'm about to tap the info buttons.
This shows an action sheet
Yes I do need all though buttons, tap on the second one
OK, it switched me to the second tab.
Now I tap tab one.
All my navigation items are gone!!!
I've also tried adding a label as a title using...
self.navigationItem.titleView
However this is lost too.
My theory here is that in my action sheet clickedButtonAtIndex event (where I've running selectedIndex), the event isn't finishing correctly before it switches to the next tab.
Here's the scenario
Any suggestions ?
Since this is such a complex problem I have created a
sample project.
Take this sample code... and then run. I don't have such problem
I'm currently programming an app for iphone that uses the tab bar. One of the views it links to uses a navigation controller so that i can drill down the table view that I am using to display info to the user. It all works OK I can drill down the table view no problem, i can push the current table view off the view stack and return back up the stack to the first view using the back button in the navigation bar.
The problem I have is that if I drill down more than 1 view level and press the tab bar button for that view the application exits and Xcode shows a EXC_BAD_ACCESS.
The tab bars button is obviously trying to jump back to the first view in the stack, but should it be doing this?
If so, how do I make the button push everything from the stack or is it possible to disable the tab bar button from that view trying to show the top view again?
Its not really desirable for the whole app to return to the first view if the user accidentally taps the button.
Any help appreciated :)
I had an autorelease set on the view object I was trying to link back to from the tab bar and hadn't noticed that I was also releasing the same object in the dealloc method also. So when I viewed the view the first time I clicked the tab it was still in memory but when coming back to the view its retain count had been set to zero removing it from memory altogether.
Solved it by removing the release cal in the dealloc method. Alternatively removing the autorelease would have done the same thing.
I have 6 view controllers on a UITabBarController. Each of them has a UINavigationBar at the top of them (Not linked to a UINavigationController), for showing the title of that view controller, and some buttons for controlling it. This was fine while I had 5 controllers, as no 'More' button would appear, but when I add a 6th, the more button appears. The tabs under that end up having two UINavigationBars! One is the one I added, with my title, the other is created by the TabBar and has a 'Back' arrow to go back to the more page. How can I fix this, either by merging them or otherwise?
Thanks, if you want screenshots just ask.
Here's a screenshot
The brown one is a UINavigationBar subclass I made, and added to the view in IB. The other one was added by the Tab Bar controller.
Yes you will need to merge them.As you need more tabs so More controller will apear and once you navigate in, it will put back button(more). In order to solve this and maintain your brown navigationBar you will need to use navigationController for those tabs in more(only for extras, not for all). This will put more(the back button) on your navigationBar.
But Remember In more you will have edit option also using which user can change position of tabs. So in that case this problem may reappear for other controllers. So please check if you can disable the editing of tabs(rearrangement). If not then you should think the same for other controllers also(in other tabs)
Thanks,
Ok, Followed all of your tips but no luck, until: I tested this https://stackoverflow.com/a/3397506/468868
Basically, you are right #Ravin, we must wrap the items in NavigationControllers, but after that, you must specify that:
- (void)viewDidLoad
{
self.navigationController.navigationBarHidden = YES;
}
Now, I just need to figure it out how to remove the navigationController from the "More" view
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.