I have a ViewController which is embedded and second TableViewController. The segue identifier between this two controllers is "abc". And now when I click the button in ViewController I go to UITableViewController. Back button in TableViewController shows me automatically. And now:
How can I add action to this Back button? I need is because I need to send some data from TableViewController to ViewController
Make sure you have embedded the navigation controller and make sure it is the initial view controller .
open your table view controller in the storyboard and where the back option is present drag a button at that place . Connect the button into the file of the tableView controller as an 'action' and write your code.
Related
I'm building a todo list app. So far I have a tableViewController in which i have the list of todo created and when I click on it a viewcontroller opens with the content inside. I have a navigationController linked to the tableviewcontroller, and tableviewcontroller linked to viewcontroller.
What I want to do now is create a new viewcontroller with an input inside, you insert your name and after clicking on a button it opens the tableviewcontroller with the list inside.
Is is the same way as linking tableviewcontroller to viewcontroller or is there a difference ?
[EDIT]
Here's what I've got so far :
Say you want a new view controller to pop up when clicking on create button. drop another view controller on your storyboard. Connect your button to that view controller using segue and set type as Present Modally. Now when you click on the button, the new view controller will show up.
Now add a button on the new view controller, connect to code using an IBAction. In the action, call self.dismiss(animated: true, completion: nil) Now when you click on this button, your new view controller will be dismissed.
Finally, add your create new use stuff on your new view controller, and pass data back to your table view using unwind segue, which you can search on Google.
Your story board will look something like this
you remove navigation bar in all controller than accepted action clicked event for viewing controller present.
your login view controller to table view for applay push view controller code and back for pop view controller code apply.
3.you search in google table view to detail view you will get exact idea how to pass data tableview data to view controller in show data ...
I have to view controller, One has a button and the other is embed in a navigation controller. I Don't know how to make a proper segue to that second view controller including a back (unwind) segue. That is in swift.
You're going to use a navigation controller. Go and select your view in the storyboard, and select Editor -> Embed In -> Navigation Controller. Do the same for the second view. Now, add a button in the first view that connect to the second view on a click. Make sure when you drag and drop that it's a push segue.
Voila! You should now have your navigation controller working.
This is my current storyboard.
I have an initial view (Activity) embedded into a Navigation Controller, which has a top left navigation item (barely visible button) which segues to a menu (Guillotine Menu View Controller) with different options. How do I set this up to open a different ViewController embedded in the same navigation controller when I click on an option in the menu?
BTW I am using this library as the menu view controller.
You can do it as follow:
New your different view controller in the storyboard.
Cmd+drag from the button to the view controller.
In the pop-up menu, select the "push" segue.
I think you need a way to make the menu push new viewcontroller to the navigation controller that presented it. I have an idea but I can't try it now, you can try it and tell me if anything isn't clear
1- Add delegate properety to your GuillotineMenuViewController
2- In prepareForSegue in your viewcontrollers if the segue is for displaying the menu, set the menu delegate to self
3- Make menu buttons' actions call the menu's delegate with the name (or better the storyboard ID) of the viewcontroller it should push
4- In the delegate function close the menu, and check if the viewcontroller isn't the one already on top, instantiate it with the corresponding storyboard ID and push it
I have an app with a uitabbarcontroller with 2 tabs.
The first tab is a mapview in a uiviewcontroller with pins that i need to call a detail tableview controller.
The second is a tableviewcontroller with a list of the same locations as before that I need to call the same detail tableview controller.
Ive added the detailVC to storyboards and added a navbar to it. how do I add a back button to that navbar that will return to the calling vc (mapview or listvc)?
I would add a segue from both the pin (pinToDetailVC segue identifier) and the list cell (cellToDetailVC), so I could add unwind segues to return to the proper vc. But I cant seem to add the back button to the navbar.
Here is what it looks like...
You want to embed the 2 view controllers into a UINavigationController, then the second view controller is pushed into the navigation controller. Then you don't need to explicitly add the back button as it will automatically be added for you. You also wouldn't need to add the unwind segues.
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.