0

I have created a custom uiscrollview and want an action on the uiscrollview to trigger a segue. I realise that all controls that trigger a segue have a "triggered segues" section in their connections inspector.

- (IBAction)startSegue....

In the .h file fits under the "Received Actions" section, is there a way to programmatically create a connection under the "triggered segues" connection to enable a custom class control to act as a connection for a segue?

Thanks D

dgee4
  • 381
  • 3
  • 16

2 Answers2

0

You can trigger a segue programatically if that is what you're asking. Create a method which is called after from action (a button or motion on the UIScrollView) and call a method similar to this: (Taken from Creating a segue programmatically)

-(void) someMethod{
MyNewViewController *myNewVC = [[MyNewViewController alloc] init];

// do any setup you need for myNewVC

[self presentModalViewController:myNewVC animated:YES];
}
Community
  • 1
  • 1
AJ9
  • 1,256
  • 1
  • 17
  • 28
  • Hi there, Thanks for your reply. I have a custom UIScrollView containing UIViews. Each UIView houses buttons. I have coded it so that pressing of any button in any UIView sends the event via protocol up to the parent UIScrollView. Is there anyway to get such a button press to trigger a push segue? – dgee4 Jul 18 '14 at 15:23
  • Why don't you trigger a method, like above, rather than send an event up to the parent? – AJ9 Jul 19 '14 at 17:57
0

No, you can't do what you're suggesting. You need to make segue from the view controller, and call performSegueWithIdentifier:sender: inside one of the scroll view's delegate methods.

rdelmar
  • 103,982
  • 12
  • 207
  • 218
  • Thanks. I have a UIScrollView which contains various UIView controls which hold various UIButtons. If any button is pressed then (via protocols) the an event in the UIScrollView is triggered. Would this be the place to perform the segue? If so how do I do this within the custom class? – dgee4 Jul 18 '14 at 15:37
  • @dgee4, it's not clear why you want the custom class to handle this. You can't call a segue from anything other than a view controller. Why not have the buttons' action methods have their targets be the view controller? – rdelmar Jul 18 '14 at 15:39
  • Managed to do it by creating a new protocol up to the viewcontroller – dgee4 Jul 18 '14 at 16:39
  • via the info here http://stackoverflow.com/questions/14106176/how-to-pass-a-value-to-parent-view-controller – dgee4 Jul 18 '14 at 16:39