I have a custom class that inherits from UIControl, to get touch events. It's basically a collection of other controls that acts as one. I'm converting my app from xibs to a storyboard. It's been mostly painless, except for this.
I drag a UIView into my scene, change the class to my custom control, hook it up to outlets on my ViewController. What I want to do with the control when it's clicked is perform a (push) segue to another ViewController. But the outlets in the designer aren't there for my UIControl to set up the segue.
Is it possible to do this? If so, what do I do to the class to enable that?
To create a segue between view controllers in the same storyboard file, Control-click an appropriate element in the first view controller and drag to the target view controller. The starting point of a segue must be a view or object with a defined action, such as a control, bar button item, or gesture recognizer.
Assigning an identifier for the segue: Select the segue, from the attribute inspector you'll see "Identifier" text field, that's it! make sure to insert the exact same name that used in performSegueWithIdentifier .
I don't think so. Looking at the Connections Inspector pane, UIButton
and UIBarButtonItem
instances get special treatment—an extra "triggered segues" action you can connect to adjacent view controllers:
While changing your view's class to a descendent of UIControl
makes the standard suite of control events available, unfortunately Interface Builder does not let you hook up a segue. The best you can do is create a manually-triggered segue from your view controller to another, then connect your custom control to an IBAction
method that performs the segue programmatically:
- (IBAction)performManualSegue:(XYZCustomControl *)sender
{
[self performSegueWithIdentifier:@"manualPushSegue" sender:sender];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With