I have a splashscreen which is shown for 5 seconds. After this time I call another ViewController(VC_Products) programmatically with a seque and want to pass parameters, but my ViewController does not receive anything.
override func viewDidLoad() {
super.viewDidLoad()
//here we set a timer to start after a given amount of seconds the ProductViewController
_ = Timer.scheduledTimer(timeInterval: 5.0, target: self, selector: #selector(timeToMoveOn), userInfo: nil, repeats: false)
}
@objc func timeToMoveOn() {
//change root navigation controller
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.changeRootViewControllerToSWRevealViewController()
self.performSegue(withIdentifier: "splashscreen_to_products", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if (segue.identifier == "splashscreen_to_products") {
if let vc: VC_Products = segue.destination as? VC_Products {
vc.titleremote = "variableToPass"
}
}
}
In the VC_Products:
I have following:
var titleremote:String = ""
and it does not change to "variableToPass". Nothing happens! Why?
UPDATE:
Seemed that changing rootview controller to SWRevealViewController was the cause why I could not pass parameters. I removed the SWrevealViewController and it worked. Somehow, I need the SWRevealViewController to have a left menu, but then I am not able to pass data. I wanted to load images from remote URL in splashscreen and pass them then to a VC_Products where the images are presented. This is not possible. I searched for two days finding a way to pass the image thorugh the SWRevealViewController, but without success. I will now go a different way and save the loaded image in the splashscreen to temporary folder and just load the images from there in the VC_Products. That is what I hate about iOS coding. Storyboard and the whole navigation between controllers is horrible as the layout constraints and debugging is in iOS. In Android it just works without any problems.