I have a viewcontroller and I need to pass an ID to a secondViewController that will be present as page sheet after click a collectionViewCell. I tried to pass the ID using a instance of the secondViewController but that didn't work I tried using segue as well but It didn't work either.
            Asked
            
        
        
            Active
            
        
            Viewed 29 times
        
    1
            
            
        - 
                    1Can you share part of the code(how did you pass the id) so that we can know what the problem is? – sudayn Dec 05 '20 at 12:06
1 Answers
1
            
            
        Second View Controller
class SecondViewController: UIViewController {
//Add id property
var id: String = ""
override func viewDidLoad()
    {
        super.viewDidLoad()
        print(id)
    }
}
First View Controller
let secondViewController = initialize your controller
secondViewController.id = data you need to pass
secondViewController.modalPresentationStyle = .pageSheet
self.present(secondViewController, animated: true, completion: nil)
 
    
    
        sudayn
        
- 1,169
- 11
- 14
- 
                    Thanks, your answer solves the problem of pass the id but the ui doesn't show the viewcontroller as pagesheet just makes the animation and put the current viewcontroller behind. – Ivan Mosquera Dec 06 '20 at 04:46
