How To Make Ask View Controller iOS - ios

I need to make "ask for something" view controller in my iOS application.
This is storyboard. When I click start button (customised button), I need to go to "second one table view controller", select there an item and pass that data that I selected back to "hidden one view controller". Which segue should I use in storyboard, and how should I pass data in code?

First of all you have to use a UINavigationController.
Drag it from your Object library and drop it in your storyboard.
It should present a UINavigationController and its rootViewController (a simple UIViewController). Delete the rootViewController and use ctrl + drag (as if you wanted to create a new segue) to make your controller the UINavigationController's root view.
You will have to do the same ctrl + drag to create a new segue from your first controller to the second one. but this time select push action segue.
If this is new for you, you should try this awesome course from Stanford:
https://itunes.apple.com/us/course/developing-ios-7-apps-for/id733644550
It covers everything you need to make your app on iOS. If you don't have time, at least watch the 11th lecture viedo 11. Table View and iPad.

Related

Xcode / Swift: How I implement a back button?

I just started with Xcode and Swift.
I try to build my first little App for iOS. But now I have the problem, that I don't know how to implement a the back button, so that i come back to the view before.
My Storyboard look like this:
When I open the A-Z view, I want to display the Back Arrow, which turn me back to the Item 2 view.
To open the A - Z view I connect the button "Medikamente A - Z" with the Navigation Controller.
When using storyboards the back button is usually implemented with unwind segue.
I usually like to follow raywenderlich toturials on UI related topics, like this - http://www.raywenderlich.com/113394/storyboards-tutorial-in-ios-9-part-2
It include a detailed example of how to implement back button in storyboards. Quoting from it -
Storyboards provide the ability to ‘go back’ with something called an unwind segue, which you’ll implement next.
There are three main steps:
1. Create an object for the user to select, usually a button.
2. Create an unwind method in the controller that you want to return to.
3. Hook up the method and the object in the storyboard.
When using UINavigationController, whenever you push to a new ViewController the back button will automatically appear, so you can jump back to the previous View Controller.
So it's works like:
UIViewController -> UIViewController -> UIViewController
A back button will appear on the last 2 so you can pop back the the previous ViewController.
You don't have to do any additional coding for the back button to appear, it'll do it on its own. I hope this clears it up. Let me know if you have any questions.
To implement a back button, your root view controller has to be a Navigation Controller.
The first view controller becomes the navigation root of the navigation controller.
If you want to present another view controller, you select a "Show Detail" relationship as the action for the button which should show the view controller. To do this, Ctrl-click and drag from the button to the destination view controller and select "Show Detail".
I had the same problem, even when on the storyboard the back button was visible at design time.
I deleted the segue, and recreated it with "Show" instead of "Show detail". Changing the segue to "Show" had no effect. I think this is a bug, so if you miss that back button delete and recreate the segue.

How to design a mechanism to manage viewcontrollers transitions, like route

I want to design a routing mechanism for management view controller transitions in objective-c.
Two view controllers, without reference to the other side of the pointer, the transition is completely controlled by the route.
How to achieve the route?
Thanks for your help.
I hope you think like this.
Route = Segue (In Xcode)
Take Two View controller
Make 1st Embed in Navigation controller (Which is must be initial View Controller)
Put One Button in 1st VC
Press Ctrl + Drag Mouse from button to 2nd VC (One popup will be show, then select Push)
Run Project
Press Button
Lol
You can use Storyboard's segues. Create view controllers and segues between them. You can use Push Segue or Model Segue. Push Segue will let you pop next view controller too, and you will have to embed your first view controller into navigation controller. For Model Segue, you can move from one view controller to another but to return to previous view controller, you will have to create another segue.
I think I find the approach to answer this question。 Here is the similar project.

Proper way to segue between two simple View Controllers in iOS 7

I'm mainly from a C# background, so the workflow for iOS is a bit unusual for me, at least for now.
I was having a problem having simple segue from a main menu, to a another menu/work area, and then with the ability to go back to the main menu.
For a test, apparently I did something wrong.
I didn't write any code for this test to exhibit the problem.
What I did was just,
create a new single-view app
drag an additional view controller onto the work area
drag the start arrow to the new view controller (so it becomes the initial view, same thing as checking the checkbox to set it as the initial view)
added a button to each view controller
Ctrl + clicked and dragged the buttons to the opposing view
for the segue type, I chose "replace"
now the program crashes if I hit the second button to go back to the "main menu" (green view controller in this example)
So what am I doing wrong? Do I need to add some form of delegate or something?
I did find this, though it present fewer segue options in the tutorial than what I have.
https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/SecondTutorial.html
These are the options I have when I Ctrl + Click from a button to another view
-Push
-Modal
-PopOver
-Custom
-Replace
"Have you embedded a navigation controller? You need to go to editor->embed in-> Navigation Controller. You need a navigation controller for push segue. – Kaushal Bisht"
This solved it for me. Now I'm just going to work on replacing the navigation bar with custom UI controls.
Thanks everyone! :)

Trying to add 3rd tab to tabBarController

I'm trying to add a 3rd tab to the tabBarController using ios5. The standard object you get when you drag it out to your storyboard has 2 tabs. Does anyone know how to do this? I searched the internet and all examples start with their tabBarController with the extra tabs without showing how to get it.
Here is the video I watched that taught me how to add a third tab to a TabBarController:
Tab bar for Xcode Swift for iOS
I will summarize the process below.
Create a new Tabbed Application project
This will automatically provide two tabs that already "just work".
Add new View Controller
Drag another view controller onto the storyboard.
Add Tab Bar Item
Drag a Tab Bar Item onto the new View Controller that you just added.
Connect to Tab View Controller
Click and Control-Drag from the Tab View Controller to your new View Controller. A menu will pop up. Choose the view controllers option under the Relationship Segue group.
That's it. You should be able to run it now and have all three tabs work. Watch the video that I linked to for more details.
Note:
To do anything on your new tab, don't forget to add a new View Controller class (as you would for any new View Controller).
Based on Wolvorin and Tom van responses, and based on what I have experienced you should do as following:
Create an empty View Controller (in Controllers and Objects)
From Windows and Bars, drag Tab Bar Item to the newly added view
From the main View Controller, select Tab Bar Controller icon (next to First Responder), and Control-Drag to the newly added View
BOOM you have new tab
To expound on #Roozbeh 's answer, when you control drag from the Tab Bar Controller to the newly added view controller, make sure you select the view controller option under Relationship Seque
I was reading this question after having the same problem and I wanted to clarify what the exact step was.
for third tab first add a view controller and then right click the tabview controller and then from it's storyboard segway from relation controll drag to the added view controller and it's done
Look in the right part of the screen, I believe it's the Objects library view. Just find the "Tab Item" (or something) and drag it into the bar.

In an iOS 5 Storyboard, how do you push a new scene to the original view controller from a Popover?

I'm creating a popoverSegue from a new view controller and want to push a third view controller onto the original stack. This is how I'm creating the application:
Create a new Single View Application
Select Use Storyboards
Select the MainStoryboard.storyboard file.
Select the only View Controller, change the Title and Identifier to initialView, then select Editor->Embed In->Navigation Controller
Drag two new View Controller objects from the Objects Library onto the canvas
Change the Title and Identifier of the new View Controllers to: popoverView and newView.
Add a Round Rect Button object from the Object Library to initialView and popoverView.
Add a Label object from the Object Library to `newView.
Control click the button in the initialView and drag to popoverView.
Select the Popover option from the Storyboard Segues menu that appears.
Control click the button in the popoverView and drag to the newView.
Select the Push option fromt the Storyboard Segues menu.
Build & Run.
Click the first button, and the popover appears, but when you click the button within the popover, nothing happens (it should push the new view but doesn't.)
What I want to do is for it to push onto the Navigation Controller stack, but am not sure how to setup the storyboard for that.
Any ideas?
You're expecting the UINavigationController hierarchy to extend itself into a presented popover. It won't. The same goes for presenting modal view controllers. If you were to log self.navigationController in popoverView, you would see that it is nil.
Embed popoverView into it's own UINavigationController. Remember that if you're overriding prepareForSegue:sender: and attempting to configure the popover, you will need to get the topViewController from destinationViewController as the destination is now an instance of UINavigationController.
Sounds like it should work, but if it doesn't try the following:
1. Click the segue that doesn't work and give it an identifier. Let's say it's PopoverToNewSegue.
In your implementation file for the popover view controller, add an action when the button is clicked.
That function should return void and add the following line:
[self performSegueWithIdentifier:#"PopoverToNewSegue" sender:self];
That should get your segue running. I've noticed that segues don't always work like you expect them to, but this one works for me without fail.

Resources