segue

Sending data with Segue with Swift

浪子不回头ぞ 提交于 2019-11-26 02:35:32
问题 I have two view controllers and two views. In my first view, I set the variable \'currentUser\' to false. I need to be able to set \'currentUser\' to true in the second view controller. When trying to reference \'currentUser\' from the second view it\'s not picking it up as \'currentUser\' is defined in the first view controller. How do I carry across variables with segue? 回答1: Set values from Any ViewController to a Second One using segues Like this: override func prepareForSegue(segue:

Passing data with unwind segue

我怕爱的太早我们不能终老 提交于 2019-11-26 02:22:54
问题 I created two view controllers. I created a segue from the first to the second to pass data. Now I want to pass data from the second view controller to the first one. I went through many similar questions and I\'m not able to implement those as I lack the knowledge on how unwinding works. ViewController.swift class ViewController: UIViewController { var dataRecieved: String? @IBOutlet weak var labelOne: UILabel! @IBAction func buttonOne(sender: UIButton) { performSegueWithIdentifier(\

IOS - How to segue programmatically using swift

╄→尐↘猪︶ㄣ 提交于 2019-11-26 02:16:46
问题 I\'m creating an app that uses the Facebook SDK to authenticate users. I\'m trying to consolidate the facebook logic in a separate class. Here is the code (stripped for simplicity): import Foundation class FBManager { class func fbSessionStateChane(fbSession:FBSession!, fbSessionState:FBSessionState, error:NSError?){ //... handling all session states FBRequestConnection.startForMeWithCompletionHandler { (conn: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in println(\

Segue and Button programmatically swift

笑着哭i 提交于 2019-11-26 01:54:53
问题 I am using iCarousel and I have to create my own button. I want to pass data from the button made programmatically to another view, but I don\'t have a segue identifier because I created the button programmatically. I don\'t know if it is possible to create the identifier of the segue programmatically. button.addTarget(self, action: #selector(buttonAction3), for: .touchUpInside) button.setTitle(\"\\(titulos[index])\", for: .normal) tempView.addSubview(button) let myImage = UIImage(named: \

How to perform Unwind segue programmatically?

这一生的挚爱 提交于 2019-11-26 00:35:31
问题 Using storyboard this is very easy. You just drag the action to \"Exit\". But how should I call it from my code? 回答1: Create a manual segue ( ctrl -drag from File’s Owner to Exit), Choose it in the Left Controller Menu below green EXIT button. Insert Name of Segue to unwind. Then, - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender. with your segue identify. 回答2: Here's a complete answer with Objective C and Swift: 1) Create an IBAction unwind segue in your destination

Creating a segue programmatically

元气小坏坏 提交于 2019-11-26 00:16:31
问题 I have a common UIViewController that all my UIViewsControllers extend to reuse some common operations. I want to set up a segue on this \"Common\" UIViewController so that all the other UIViewControllers inherit. I am trying to figure out how do I do that programmatically. I guess that the question could also be how do I set a segue for all my UIViewControllers without going into the story board and do them by hand. 回答1: By definition a segue can't really exist independently of a storyboard.