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:
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 yourartistsDetailViewController, you can do it inprepareForSegueYou 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
modalTransitionStyleproperty onartistsDetailViewController.Navigation back is controlled by adding a ‘dismiss’ button, with an IBAction something like this…
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.