Wednesday, October 21, 2026
HomeiOS Developmentios - Including segues programmatically to things that don't exist within the...

ios – Including segues programmatically to things that don’t exist within the storyboard and displaying their respective attributes

[ad_1]

The conduct of my app entails including views (constructed programmatically inside a struct) from one other controller to the primary controller. The specified conduct is that when these views are added to the primary controller, I can faucet on a view and it’ll segue into one other view controller displaying the article’s respective attributes.

I have been tirelessly making an attempt to determine this out, however I don’t know how I might lay it out. That is what I’ve now and roughly how I am imagining it:

struct View {
   var newView = UIView()
   var newLabel = UILabel()

   init(viewName: String) {
      newLabel.textual content = viewName
      newView.addSubview(newLabel)
   }
}
view = View(viewName: "view1")
view1 = View(viewName: "view2")

override func put together(for segue: UIStoryboardSegue, sender: Any?) {
   let destinationVC = segue.vacation spot as! MainViewController
   destinationVC.mainStack.addArrangedSubview(view.newView)
   destinationVC.mainStack.addArrangedSubview(view1.newView)

}
  • View 1 and View 2 are stacked on the primary controller
  • View 1 comprises labels reflecting its object’s attributes
    • Faucet on View 1
      • Segue to Information controller exhibiting View 1’s attributes
  • View 2 comprises labels reflecting its object’s attributes
    • Faucet on View 2
      • Segue to Information controller exhibiting View 2’s attributes

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments