Can not pass Data To ContainerView

Related searches

I have tried 2 methods to pass the data from ViewController to ContainerView, with and without segue Here is without segue method

ViewController

 class DetailPostBookReviewVC: UIViewController {

        var postid: String!

        @IBAction func Menubutton(_ sender: Any) {

        print(postid!)

        let storyboard = UIStoryboard(name: "Main", bundle: nil)

        let vc = storyboard.instantiateViewController(withIdentifier: "MenuBookReviewVC") as! MenuBookReviewVC

        vc.favpostid = postid
 }

ContainerView

class MenuBookReviewVC: UIViewController {

    var favpostid = String()
     @IBAction func Deletepost(_ sender: Any) {
        print(favpostid)
    }
}

result: favposid has Nill Value

UPDATE this is with segue method

class DetailPostBookReviewVC: UIViewController {

     var postid: String! 

     @IBAction func Menubutton(_ sender: Any) {       
        print(postid!)

     func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?){

    if (segue.identifier == "toMenuBookReviewVC") { //"toMenuBookReviewVC" is identifier 

       let vc = segue.destination as! MenuBookReviewVC
        vc.favpostid = postid!
    }
}

Pass your data like. User prepare(for:sender:)

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if
        segue.identifier == "MyIdentifierInStorybiard", // Set that
        let controller = segue.destination as? MenuBookReviewVC {
        controller.favpostid = postid
    }
}

How to Pass Data to an iOS Container View, to pass data to the container view. This is a great question because the answer is not obvious to a person just learning iOS. In this post, I will� SecondViewController // Pass data to secondViewController before the transition } } But what about embed segues and container views? Though it may not be obvious to people learning iOS, this function is also called to prepare for the embed segue that happens when a parent view controller contains a container view.

I think you postid is not String type so print the null value

How to pass data from container vi…, And prepare segue is not executed but performSegue works well. Can I send the data from container view to other controller directly? Are there any solutions? As title, i’m trying to pass value of slider to containerView but it’s not work here’s my code: class ViewController: UIViewController { @IBOutlet weak var ValueLabel: UILabel! @IBOutlet weak var sliderControll: UISlider! override func viewDidLoad() { super.viewDidLoad() sliderControll.maximumValue = 5 sliderControll.minimumValue = 0 sliderControll.value = 0 sliderControll.isContinuous

For Passing Data To Container View you can use this

UserDefaults.standard.set(value, forKey: "SomeKey")

after your data is used you can clear that default value.

UserDefaults.standard.set("", forKey: "SomeKey")

Pass Data Between View Controllers – LearnAppMaking, You can do this by choosing File -> New File , then Cocoa Touch Class, then create the SecondaryViewController class. Don't forget to tick the� Can not pass Data To ContainerView Pass your data like. User prepare(for:sender:) override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "MyIdentifierInStorybiard", // Set that let controller = segue.destination as?

How to pass data between two view controllers, Passing data forward is used when you want to show some information in a detail view controller. For example, view controller A might contain� This VC2child needs the data from VC1 and I don’t know the best way to do that. I’ve scoured the internet for nearly 24hrs and I haven’t found the right way to do this. I know how to segue and pass data from VC1 to VC2, but I need one step further (getting the data to VC2child).

How to pass data to container view? : swift, Hey guys, I've been having trouble with passing data from my view controller to my container table New comments cannot be posted and votes cannot be cast. same like with 2. You have one ViewController you want to show so that the alpha value of that one is 1.0. All others should not be viewable so you set them to 0.0

ContainerView is designed to add a cool swim from the bottom to the animation with the effect of scale, controlled by the help of a gesture, scrollView also takes control. The idea is taken from th

Comments
  • How you push MenuBookReviewVC? Via storyboard?
  • How you doing with segue?
  • Ketan Parmar: i used func prepareForSegue for segue method but failed
  • have you set segue from button to view controller? or view controller to view controller? If you have set vc to vc then you need to call performSegue on button click. And make sure you have set identifier of the segue and yo're using that identifier in the code!
  • do you mean I create func prepareFor Segue and create one more func performSegue, putting to Button Action?
  • I have tried this method but unfortunately failed. My container view is a slide up menu. When I click the Menubutton, it will come up. So I think I dont use push viewcontroller
  • postid is a varible String type I declared on another VC. I did print postid successfully and show the id as String
  • Fatal! Do not do that