Add Up/Down buttons to UITableView navigation bar - iphone

Many apps, including Apple's own native Mail.app on the iPhone implement an Up/Down button in the detail view which allows for quick and easy browsing. I wish to create such an interface in my own app, but am struggling to do so. So far I've setup a segmented control which links to an action in my navigation bar, but I'm struggling with what to put in the action to make the detail view for the table update when the user presses the "Up" button or "Down" button to navigate to the item before or after the current one.
Any help would be appreciated. Thanks.

It depends on how you have your data set up, but why can't you hook into your existing code? What are you doing in your existing code to refresh the detail view when a user selects a row in master view table? Can't you just call that method directly?
It's hard to give specific advice without more detailed information on your current design.

Related

How can I toggle a UITabBarController's button destination between two ViewControllers

I'm a bit stumped with this one...
Consider this app:
The app has a tab bar navigation at the bottom with buttons recipes, favourites and settings
Recipes can be shown in two ways - either as a list, or as an grid of images.
The user can toggle between the list and grid views by pressing the toggle button and the app should remember the previous setting.
So...
I boot the app and press the Recipes button.
I'm looking at the recipes as a list and I press toggle
The screen flips (via UIModalTransitionStyleFlipHorizontal) and now I can see the recipes arranged as a grid.
I press settings to change some settings.
When I press Recipes again the recipes should still be listed as a grid.
When I press the toggle button, the recipes are shown as a list again etc.
The Problem...
Assuming the list view is the default, how do I tell the newly instantiated grid view that it should use the same TabBar as the list view?
How can I make this transition look seamless?
I understand that I shouldn't use one controller for multiple views, or one view across multiple controllers... Should I use a separate view/controller for each screen here or use the same and show/hide subviews as required?
All advice appreciated
You need two separate ViewControllers for both screens.
If you want to make it as you show, take Xcode template called "Utility application" as a base.
I believe better to use here UITabBarController.
I recommend you also to read Human Interface Guidelines from Apple.

iPhone view with pop up animation?

I'm new to iPhone development, its going OK so far, I've managed to get to grips with the Tab bar, navigation bar and tableviews.
However I want to be able to copy what the settings app does on the device when a user wants to change language.
In Settings, General, International when a user clicks on Language a new screen animates over the previous screen with a navigation bar that has a cancel and done button and a table view showing the languages available for selection.
I cant seem to find how to do this via Google so I was wondering if someone could point me in the right direction of a tutorial or what I should be searching for? Is it type of view or a certain way to animate a view?
This is done via a method available on UIViewController (and thus all of its derivatives as well) called - presentModalViewController:animated:. You simply need to create a new view controller that you want to display and pass it into that.
See the link to the UIViewController docs above for more info and the complementary method - dismissModalViewControllerAnimated: to close the view. The docs have links to example code on how to use them as well.
in iPhone, it's done through modal view controller. Refer this tutorial.

View-Based Application? - Please explain

XCode: "This template provides a starting point for an application that uses a single view. It provides a view controller to manage the view, and a nib file that contains the view."
What does that even mean? (ie what does Single view actually mean)
1) This means that your application will only have a single view screen that is active
2) This means that your application will be able to have as many screens as you like using a single view controller.
Ok now what if your application has multiple screens? not a single view screen, is still suitable under a view based application template?
Example
Screen1(main): on this screen you have 3 buttons, "Open Form1", "Open Form2", "Open Form3"
When the button is clicked it opens up the associated screen,
Press the "Open Form1" button opens up "Form1" screen2
Press the "Open Form2" button opens up "Form2" screen3
Press the "Open Form3" button opens up "Form3" screen4
When the user completes the form and submits it, a thank you screen is displayed
therefore in this example there would be a total of 5 screens.
Each form screen contains is different, textfield inputs, and information, is this considered as a view based application?
View-based app is just a template to say that your app will be view-based. That means that you can have any number of views you want, as this template comes with a view controller (that, as the name says, can be used to control the views... show/hide them with animation, for example).
The template starts with ONE VIEW that is added to the app view controller. You can add any number of views to that controller.
So, yes to your questions. You can use this to create the app you mention, where any of the "screens" you mention would be a view, for example and you can show each one using, for instance, the app view controller to animate each view showing or hiding.
That means the template will create one view and corresponding view controller along with app delegate, main window. That will also do the necessary things to add this view to main windows, and load when app runs. This is just a template. Then you can crate any number of views and view controllers as you want.
This means that the template you are starting the project with provides a single ViewController, and associated XIB for the View. As the first answer says you could use this template to build the application mentioned.
HOWEVER you may wish to think about how the user is going to interact with your app. Will you allow stepping back and forwards through the screens, in which case you may want to consider the Navigation Based app where you push/pop screens onto a stack to allow easy movement between then.
You might also have a concept of allowing the user to jump at will between each of the screen pages in which case you might want to implement a TabBar application.
Or you could just implement it all yourself. At the end of the day it will be your application design, and the template is only a starting point to get you going. I would suggest that if you are starting out with iOS development however to go with 1 ViewController matched a XIB for each screen you wish to implement to keep things simple.

iphone persistent button on all views

I have a navigation app that has many screens the user navigates to. A handful of views manages these screens dynamically. What I want to try to do is add a button that will always show up on every screen the user views. I need to do this so that the user is always able to preform the action associated with the button regardless of where they are in the app.
Is it possible to achieve this by adding this button only once and having it passed between views like my navigation bar is? Or do I just have to man up and add this button and its functionality to every single view file I have?
Thanks
I would say it probably depends on what the button does. If the button is generic to all views, meaning it affects all views the same exact way so no customization for a given view is needed, then a way to do this would be to include the function in the App Delegate or as a subclass to your Navigation controller.
You can then use the rightBarButtonItem to always show the same button and just access that method. You would just have to add code for the rightBarButtonItem in each viewDidLoad (but they'd all be the same).
I did something similar to this with an "Upgrade" button on one project. Since all the button does is launch the AppStore to the paid version, it's independent of all views and I can place it anywhere.
You can put the button on the navigation bar if you want. Alternately, the more generic way to do this would be to split your single view into two views. One is small and only contains your button but always stays on the screen. The second is your workspace and you swap in and out the views that are displaying the current content. You'll note that this is the way the navigation controls and tab-bar controls work.
The last way to do this would be to put different buttons, in the same place, on each view and have them all trigger the same action. As far as the user is concerned this looks like the same button. Disadvantage here is that you can't alter the button across all views in a simple manner.

Modifying code to add a home button

Currently the code I need to modify uses a tabBarController with a single selection inside it which takes the user back to the root view, but because it is a tabBar then the whole of the tab is selectable and I need it so only the button positioned in the middle of the tab bar is selected.
I am fairly new to this but know it is not a tabBar that is needed here but something else, maybe just place a button there. Any help would be fantastic. I would post the code up but I am unsure which section would be required. I hope I made myself clear enough :)
Rowley
Tab bars are for switching among different views. If all you want is a home button, a tab bar would not be a good choice. You could use either a simple UIButton, or possibly a tool bar -- though the tool bar is generally used when there is more than one action the user might take.