UIPickerView selection link to UITableView - ios

How do I link a UIPicker view on one scene to a UITableViewController? I have a picker view in one view controller populated with a number of categories, I want to segue to a table view controller when a category is selected/pressed.

First, create the segue in the Storyboard by Ctrl-dragging from the view controller to the new TableViewController (don't link from the picker, link from the view controller in which it appears). Select the segue and give it an appropriate identifier. In your UIPickerView delegate, implement the pickerView:didSelectRow:inComponent: method, and save the selected rows/components to properties. Then invoke performSegueWithIdentifier:sender: to trigger the segue.
Separately, as part of the prepareForSegue method, read the properties you previously saved, and set the relevant properties of the segue destination view controller.
NB you may find, though, that this will trigger if the user hesitates whilst spinning through the picker view options.

Related

How can I create a custom segue from a custom collection view cell (cell created using xib) to a tabBar controller

I created a collection view that has custom cells created using a .xib file. I need to create a custom segue that goes to a specific tab of on a tabBar controller depending on the label of the button of the cell. The collection view is basically used as a menu for going to a specific tab of the tabBar controller.
The xib of the custom cell of the collection view has a class of its own. The cell has a button. On clicking the button I need to perform a custom segue (because i need custom animation) from the view controller to the tabBar controller. The collection view is present on the view controller.
Maybe you should explain better the state of the views in order to know if you want to push to another view or simply change the current tab. Anyway, I think you don't need a custom segue, just use the didSelect of the cell, e.g. for obj-c
tabBarController.selectedViewController = [tabBar.viewControllers objectAtIndex:SPECIFIC_TAB];

Why UIBarButtonItem doesn't call IBAction before segue?

My question is very similar to : Swift: Make button trigger segue to new scene
The issue is:
I have a view controller, with a button that causes another view controller to appear modally.
I have Ctrl+Click from the button to the second View Controller, and created the segue in IB.
Then I Ctrl+Click from the button again to the source code of the view controller to create an IBAction method.
I assumed that the button will do two things now: a) call the IBAction method , and b) perform the segue.
What happens is only the segue for some reason.
When I delete the segue, or remove the call to the view controller from IB, then the IBAction is called, but Xcode tells me that the second view controller is not reachable now.
I want to be able to present an ActionSheet to the user and then be able to performSegue to the second view controller, based on what the user selected from the action sheet.
I know I can programatically call performSegue but that requires the creation of the segue and attaching it to a physical button in IB, which defeats the purpose of not calling the IBAction that button may already have.
If I want to do some additional steps before calling the segue I usually attach an IBAction to the UIButton and call the perform segue from within this, in the code. You can add a segue to the storyboard and give it an ID, without having to connect it to a button. You do this by control-clicking on the viewcontroller and drag to the next viewcontroller in the storyboard.
Connecting a segue from storyboard will automatically always perform the segue. You can do any preparation for transitioning to the new view controller in the prepareForSegue method.
If there is some logic that comes before, like a user selecting something from the action sheet, just use the IBAction and then perform the segue with performSegueWithIdentifier based on the user selection. However, you do not have to create another button, just ctrl+drag from one view controller to another and give the segue an identifier.

How to disable storyboard segue but still use segue identifier?

When I transition from a table view cell to another view controller, I can connect it on storyboard. However, this doesn't allow me to use didSelectRowAtIndexPath: method even when I want to use selected row and indexpath logic or pass a value between the two view controlelrs to make a transition.
But when I disable the storyboard segue transition, I cannot set segue identifier and hence cannot call performSegueWithIndentifier: method from within the above method.
So how can I use didSelectRowAtIndexPath: and still perform a segue? If I set my storyboard segue and at the same time define didSelectRowAtIndexPath:, my app crashes after I return back to the original view controller.
Just create your segue from the viewControler button (yellow button on bottom) of viewControler1 to somewhere in the viewControler2

ViewController Link to interface builder

I'm a newbie in ios development... I created a Windows based application. How do I link a view to a controller I created? How do I go to the next view when button is clicked?
You generally don't link a view to a view controller -- it's the other way around. Add an IBOutlet to your view controller that will point to the view in your .xib or storyboard. Then, in IB, drag a connection from the view to the view controller and choose that outlet. This process is described in detail in Apple's documentation.
To move to the next screen when you click a button, you'll create an IBAction method in your view controller. You can then drag a connection from your button to that view controller and select the action. When the button is tapped, the action method will be sent. The code in the action can then call an appropriate method to transition to the next controller. Alternately, you can use storyboards and segues, and have the button trigger a segue to the next view. You'll find a description of the target/action system in the same document that I linked above.

Segue between ViewControllers without trigger control?

Is there a way in Storyboard UI to connect two UIViewControllers by a segue, without setting an object (Button, cell, ...), triggering the segue?
I want to fire the segue in code with performSegueWithIdentifier:sender: programmatically.
Why i want this is, i'd like to display a detail view controller, when a tableviewcell is selected, but only while the tableview is in editing mode.
You can just control-drag from one view controller to the other. And then of course don't forget to give the segue an identifier.

Resources