Swift- How do I make it so that if the user clicks the button it takes them to a new view? - swift

I'm currently trying to create a small notepad app, and i'm in need of help. I am using a Tabbed View Application. Say we had a view that has two text fields for Name and short description, and then a button beneath saying "Create Note".
How can I make this button change the view to my editor/notepad view that does not have the tabs at the bottom?
Thanks

If you are using storyboards, which I assume that you are, what you will want to use are triggered movements called segues.
To create one, right-click on the button and drag the line that appears to the second view, and then release.
It should look like this:
Then, when you release, a gray box will appear, with a list of segues. You can find out what each one does online, and as you get more advanced you can develop custom ones.
However, use Modal as a basic one to begin with.
Hope this helps,
Will.
PS. In the future, try and make your questions more specific, and do some research before you ask a question. It's important that you gain a good reputation on Stack Overflow if you want your questions answered properly.

Related

What's the best way to design this screen (like note addition in Momento app)? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I would like to create a page similar to the one where the user can add a note in the Momento app (screenshot below).
What's the best way to structure the View Controllers for this page? There is a tab-like menu in the center of the page. On the top half of the screen, is a view; and at the bottom-half, you get a keyboard (when entering text).
MY NEED : entering a note which can have three types of text (so three tabs) and a picture -> so four tabs in all.
On some analysis, goggle'ing, and thinking, I can think of these possibilities:
OPTION 1
A TabBarController with 4 tabs (but then I wouldn't be able to place the tab in the middle of the screen like in Momento app & I read (in some Stackoverflow discussions) that Apple guidelines don't recommend changing the tab bar from its natural position either.
OPTION 2
Have a view controller, say MyController. This will have 4 buttons (arranged next to each other in the middle of the screen, so that they appear like tabs).
Have one UIView object for the top-half of the page.
Have another UIView object for the bottom-half of the page.
Based on which of the four buttons is selected, I vary the content displayed in the top & bottom UIView objects.
Option 2 sounds good to me. But, I wanted to get an opinion on if it's correct, or is there some better way to achieve this? Thoughts please?
You should use a UITextView and set it's inputView as a view with those buttons. It should automatically slide with the keyboard just as you want it.
Hope this helps.
Cheers!
OK, here is where I would start. Two issues; the tabBar and handling the keyboard. The rest is just pushing a popping appropriate view controllers.
The TabBar: First Apple has some example code that deals with the Keyboard Accessory component which is probably how Momento renders their tabBarController like thingie. Here is the link. Their example handles the keyboard in a 'one off' way, unique to this particular app.
The Keyboard: As for a more generic approach to handing the keyboard, you may want to look at Michael Tyson's TPKeyboardAvoiding component on github. Here's the link for that one. The TPKeyboardAvoiding is quite nice in that it is a drop in component that handles keyboard issues for UITableView as well as UIScrollView.
One thing I haven't checked is if Mike's stuff is smart enough to handle the extra height on the Keyboard when it has an Accessory attached. (It's pretty smart though...).
Hope this helps.

One Xib file for 2 states: showing & editing a object

The contacts application of the iPhone is a good illustration of my problem. Apple uses one view to show and edit contacts at the same time. When a user wants to edit a contact he simply presses the edit button on the right side of the navcontroller. The 'show contact' interface changes to the 'edit contact' interface and the user is able to edit the contact. When the user is finished editing he presses the 'done' button.
My question is, what is the easiest way to achieve this behavior?
I believe the iPhone CoreData Recipes sample code has everything you need, they have a page that is exactly as you describe:
http://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Listings/ReadMe_txt.html
The short answer is that you can achieve this by using to separate view xibs which you can swap in and out. Personally I prefer to simply use code to hide and show the controls that need to change between the two views.

iPhone UI: No edit button for UITableView, bad idea?

I have a UITableViewController which lets the user drill down into different records. On the second level/view, the user can add and edit new records. But, I am not sure what to do, since the back button is on the top left, and I need to put the "Add" button on the top right, so there is no room (keeping to HIG) for the edit button, which would normally go where the back button is. (I am using a tab bar, so can't put it at the bottom.)
Do you think that it is logical, to expect users to know to swipe to delete a record? Or, do I need to have an edit button? If I DO need an edit button, where should I put it if I am following HIG?
Swipe to delete is a firmly established iphone UI interaction, so yes I would be comfortable expecting users to know that. We've run into the same problem a few times, and yeah you only get two nav bar buttons so you've got to make a choice. If you're already using the bottom for a tab bar, I don't see many other options.
I have a similar situation in my app.
When the user taps the edit button I show an extra table cell at the end of my table which lets them add a new record. Not sure if that's feasible in your case.
Maybe add it at the beginning, or insert a button just above the UITableView? You could then also label the button "Add/Edit" to make it clear that that's how they can add new records, although I haven't done that.
Another option would be to have that extra button or table cell always visible.

iPhone Table View Data Edit Pane

I have an application I'm working on, and I need the user to be able to add new "Shows", "Movements" and "Dots." These are all represented by classes. At the root of the application, all the shows are shown, the user can click on the show, see the movement in that show, then tap on a movement and see the dots in the movement. It works beautifully.
Now, I need the user to be able to add and edit these instances of these classes. The way I am thinking this will work is when the user clicks on the "Add Show" button (Or the "Add Movement", etc) a new view will be pushed onto the Navigation Controller. This works. When the button is pressed, a new instance of the show class is created, and passed to the new view controller. This also works. If the user wants to edit the show, then they will hit the edit button for the row, and the instance of the class (which already exists) will be passed to new view controller, and the user will be able to edit it (It should use the same view controller for adding and editing)
My question is, in the examples I have seen, it is always really dirty to create the editing view. The edit view is a table view with each row having some sort of control. Usually it is a UITextField, but it may be a slider, and it may be one where another view is popped, and the user needs to check one value. (This is similar to the address book application when adding and editing a contact)
Is there any way that is cleaner than just manually going in and creating a bunch of arrays to hold what custom table view cells need to be at what row? This gets very messy, very fast. I can do it this way, I just was wondering if there is a better, possibly faster way.
To my knowledge there's no structural solution to solve this. I'm afraid managing the cells with child UITextField or other controls yourself is the only method. This indeed gets dirty and painful very fast, I certainly feel your pain.
Although it doesn't exist, it would be very convenient if Apple added out of the box editing cells to the SDK, similar to the different normal cell styles. I haven't come across an open source project that addresses this issue, but it might exist.
If you do find a better/cleaner method to handle these situations, be sure to ping back.
as far as i know, editing mode is the only way to make the changes you describe (if i understood correctly). I agree that it doesn't seem like the most elegant approach.
http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/ManageInsertDeleteRow/ManageInsertDeleteRow.html#//apple_ref/doc/uid/TP40007451-CH10-SW19

Wizard style of interface in iPhone

How would one implement a wizard style interface for the iPhone?
For instance I have a form that I would like to break down into 5
different pages or views instead of putting all the information to fill out
into one page or view.
This interface must have the ability to go prev or next in case they want
to change something on page 2 when they are on page 4.
This interface must have the ability to go to page 3 directly and still be
able to go prev and next. Seems like using UINavigationController wouldn't
work here since views 1 and 2 are not on the stack so prev would not work.
Update: Check out the "gas cubby" application. It has what I'm looking for. UITableView presents the items you can fill out. Selecting a row takes you to the detail view to enter data and prev and next to fill in other information.
UINavigationController seems like the obvious solution. It gives you nice, familiar page transitions for free, and if you need to jump to a specific page you can just set up your navigation stack without using the transition animations.
I would say use a Navigation Controller. On the 1st view, show the 5 options in a Table View. The user selects a row, and then the corresponding section is pushed onto the stack as a new UIViewController. So, if they are in view #3 and want to go back to view #1 (to be honest, I would recommend rethinking whether or not somebody in the real world will actually want to do this), they hit "back" and then select view #1 from the table.
I can't think of a better way to do this because you won't have room to do something like breadcrumbing, which Apple would recommend against anyway. You could use a tab bar but that is more like options then some sort of wizard workflow.
If you really want them to be able to skip around the process, the combination of a UINavigation controller with a UISegmentedControl to jump to sections would do what you want. You can either embed the segmented control in the nav bar or place it just below the nav bar (which seems more like what you want since you have five sections).
If the Segmented control is not quite to your taste just put up any set of five buttons to change sections and make them visually appealing.
A "wizard" UI is typically used when you have a relatively small number of steps where one step depends on the previous, at least at some steps, the results or presentation depends on previous steps. This is like a navigation tree that usually results in the use of the navigation controller, but with only one potential branch at each each step. My feeling is that the navigation UI would be perfect, but with one exception; A button on the right hand side of the navigation bar that is the left to right mirror image of the "back" button that is usually found in the left part of the navigation button. That button would navigate to the the next step, and at each step the page presented would allow the user to fill in the information for that step. The only problem then is navigating to a step not the next or previous, and this could be corrected with a custom button that includes a drop-down list of the steps in the process. And this would fit nicely with the rest of the iPhone UI, which Gas Cubby's wizard UI (as good as it is) does not.