-1

I have a quick question for you guys that I havent found a definitive answer to. I have a app made with every viewcontroller designed in the main.storyboard. Recently I had to change out my table view viewcontroller for receiving data with collectionView in order to implement some more features.

But I have made this view programmatically. And I have made it exactly how I want it.. When I was done I wasnt sure if I could even use it with my main.storyboard made project. Atleast no similar question I have found has given me the exact answer to that.

So I figured I should ask you guys if thats possible and if it is.. if its a complicated process. This is my bachelor's thesis work so I am working against the clock.

If anyone knows, and maybe even have some tips on how I do this, I'd greatly appreciate it!

Wolfgang
  • 132
  • 11
  • Yes it's perfectly possible and not that complicated but how do you want to use it? Is it to be presented modally is it to be embedded in another view controller, etc? – Upholder Of Truth Mar 28 '19 at 08:42
  • Cheers, sounds promising. I have a main viewcontroller with some buttons leading to different viewcontrollers. My receivedDataViewController is one of them. This is where I present data sent from an arduino in a tableview. Since I couldnt do horizontal swiping and etc. with a tableview. I used UIcollectionView instead. So yes it will embedded in a nav controller from the Main View Controller. Presented modally from the main view – Wolfgang Mar 28 '19 at 08:54

2 Answers2

1

Just present the programittaclly created view controller from code:

let view = YourViewController()
self.present(view, completionHandler: nil)

Hope this helps!

1

If your viewController conforms correctly to all the necessary methods; you should be able to create a viewController in your storyboard; hook it up the way you would any other uiObject; and then set the custom class in the attributes inspector to the class of your ViewController.

If the view and not a viewController; you do a similar thing, drag the conforming type to your storyboard and subclass.

If you'd like to see your view render on your storyboard; have the object declare @IBDesignable before the class declaration.

@IBDesignable
class myView: UIView {}