I am developing an application for Iphone and I am a little lost with a particular case. This particular case is:
I have a NavigationViewController with 3 tabs for example.
On tab 1 (called "tab1"), I have a value (value 1) in a field and a button send
On tab 2 (called "tab2"), I have a table view that displays a list of values. When I click on a row, a detail view (let's call it detailview) appears with the value and detailed information concerning this value.
Once I click on send on tab1, I would like my app to send the value to detailview without going through tab2 table view. Then if I click on back on detailview I want to go back to tab2 table view.
I attached a picture of the overall. I am totally new in Programming to if there is somewhere an example of code, I would appreciate.
thank you all for your help
cheers
Related
I am running into a very strange issue here when it comes to segues between table view controller and details view.
It works with one implementation, but when I followed the same steps (& code) it doesn't work somewhere else.
Basically I have a table populated from Parse backend and once a row is clicked it would show the details for that record. For Orders View Controller, when the row is selected, it shows the detail view with a navigation in top (inherited) and a back button to the list. In the Friends Controller, when I click on a friend row, it shows the details view with details of a friend correctly. But no navigation top bar and no back button.
I also noticed the animation in the Orders scenario is different (left slide) where as in the Friends scenario (not working) it is more of coming from bottom to top.
Below are details to help assess the problem further and am glad to offer more upon request since I am not sure what part is relevant or not.
Now for the Friends scenario:
To illustrate the flow of the order, it goes like this:
I tried doing this but it didn't work:
self.navigationController?.navigationBarHidden = false
I think problem is segue between Friend view and Detail Friend view. Go storyboard and choose segue between them same config with image below:
Hope this help!
Try redoing the segue. Just Ctrl-drag from the prototype cell to the detail view controller. Make sure that you make a segue of type show.
I got 3 view controllers. On first page user defines some variables and when he executes it, it goes to second page with segue.identifier. On second page a time counter starts and an item price is decreasing over time. Whenever user uses buy button, the program prints on third page item number, updated time and price. Then if user uses show items button, he will go to the third page and see printed lines. However, I put a navigation bar with a back button on top of the third page, when I use back button, it crashes.
Here is my question: How can I fix it without changing updated price and time counter? With segue.identifier? If yes, how?
Here is what you have to do. Select the 2nd view controller, go to the edit from top and follow the path: edit -> embed in -> navigation controller.
This will automatically adds the navigation bars and back button to the 3rd controller.
Hope this helps .
Don't add your own UINavigationBar. Like Kutay Demireren said, you want to embed your first view controller in a UINavigationController, and then the segues will work by pushing each destination controller onto the navigation controller's stack.
I have two screens that I am performing a push segue between. In the first screen, there are 5 buttons that you click on to send you to the next page. On the next page, you edit some information that is specific to each button, then you click a button and get sent back to the first screen. (Kind of like editing contacts) When I edit one button it works perfectly. However, when I click on the next button and edit its information, when I come back the original screen has lost the information about the first button. Just to be clear, I am not actually editing the button. There is information that is being displayed on the button, but I am storing data in some properties on the view controller.
I think the problem is that the data stored in the properties is being cleared when I perform the segue. How can I make it so that the data persists?
Thanks to #rdelmar, I am now using a modal segue from the first view. I then use dismissViewControllerAnimated to go back. (Found in this question.)
Let's say, I have a scene (pushed view controller with a navigation bar), which displays some tabular data in a table view.
In the navigation bar of that scene I have a + sign, which should open a new scene, where the user can add a new item (row to a core data table).
In the table view, each row has an arrow on the right side of each cell, which opens a scene where the user can edit that particular item's details.
Should I use a push or modal segue for the +?
Should I use a push or modal segue for the arrow?
What is the "best practise"?
I understand the difference between push and modal segues, but I want to know which is better suited for the above use cases.
If you want to follow Apple's best practices, I would suggest the following :
For the "Add" functionality, use a modal segue.
For example look at the contacts app. Pressing + shows a modal view controller.
What's the logic ? for start, modal view controllers usually have a "cancel" button, as opposed to the "back" button on a pushed vc.
When the user presses "back" - he'd expect a way to come back to the vc. Usually "back" saves your data on iOS (auto-saved).
So by using a modal segue you force the user to submit the form , or cancel. The modal presentation hints that you really need to fill this screen.
For editing - push. but modal could work as well (and you could reuse the same VC).
Reasons for push :
you get a hierarchy of vc's , going back and forward while drilling down.
(you should implement) auto saving when going back (just like other iOS apps)
For adding a new entity to the core data table, on tapping the + button (I assume its a right bar bar button item on the navigation bar), use the modal segue.
The view for adding a new row for the enity has to be presented modally and once the save is completed, dismiss the modal view and reload the table view to display the newly added item.
Also for displaying the details of an entity row, use the push segue. A user expects a push action when he selects a table cell and it is the ideal way to do that.
I hope this quick summary will help you :
When you want to show a detail view of a summary view, use a navigation controller and Push Segues. If the "parent" view doesn't really relate as far as data is concerned to the "child" view, then use a modal. A good example for a modal view would be any entry view. This view doesn't really have any relationship as far as data is concerned to the "parent" view., the entry screen will just take data dat from user & will save & can go away & giving control back to parent
I have an app that is using a Tab Bar. My second view in the tab bar has 4 text inputs. When the user hits the 'save" button I want the the input from the text inputs to save to core data (which I have done) and then for the first view to appear. The first view has a table view which displays the data. I have been able to accomplish this but when I go back to the second view, the previous input is still in the text fields. Even worse, if I try to save this data again it seems like I am trying to save the same instance to core data. My app crashes whenever I have more than one row in the tableview, and I believe it is because of this problem.
When I select "Save" on the second view, how do I get that view controller to unload so the next time I go to that view I start off with a clean instance?