0

I have two views.

The Image of the storyboard

When I click "Sign Up" button the second view appears. When I click "Turn back" button the first view appears. It's OK.

Now I would like to call a function when I click on "Be member" button. This function will be able to send the data in the fields above it by connecting a database. However I could not create a segue.

How can I do this?

vacawama
  • 150,663
  • 30
  • 266
  • 294
Onur Tuna
  • 1,030
  • 1
  • 10
  • 28

2 Answers2

0

Welcome to SO. You need to write a clear, coherent description of what you are trying to do, with enough detail so that we know both what your goals are and specifically what you are trying that isn't working.

It is not at all clear what you are asking. Since you mention dragging, I think you are asking how to create a segue link in IB (Interface Builder) rather than how to invoke a segue in code.

How will you invoke this segue you are trying to create? From a single button, or from code? If from a button, will clicking the button always invoke the segue, and without needing any other decision making? If so, just control-drag from the button to the target scene in IB. That will create a segue and connect it to your button.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
  • When I CTRL+drag from the second view, Xcode does not allow it to be created in ViewController.swift. – Onur Tuna Oct 18 '15 at 12:52
  • Views and view controllers are 2 different things. Make sure to say view controller when you are referring to a view controller. A view is a UIView or an object that is a subclass of UIView. A View Controller is an object that is a subclass of UIView**Controller**. They do very different jobs. – Duncan C Oct 18 '15 at 13:02
  • You don't control-drag to **create** a new view controller. You should create your new view controller in IB first, then control-drag from your first view controller onto your second view controller to create the segue. – Duncan C Oct 18 '15 at 13:03
0
  1. You have added a second ViewController in the Storyboard, and you now need to add a corresponding ViewController2.swift file. See here: How to add ViewController2.swift file for second ViewController
  2. Once you have that, you can Control-drag from the button to the source code of your ViewController2 to add an @IBAction for the button.
  3. You shouldn't be using a standard segue to return to your first ViewController when Turn Back is pressed. Instead you should use an unwind segue.
Community
  • 1
  • 1
vacawama
  • 150,663
  • 30
  • 266
  • 294