0
votes

I'm trying to add a UIView into a scrollview that I have. No bugs or errors, although nothing is showing up when running the code.

Which is: scrollView.contentSize = CGSizeMake(375, 667)

let newStory:InboxStory = InboxStory()
    newStory.titleLabel?.text = "test it"
    newStory.frame = CGRectMake(0, 0, 375, 667)

scrollView.addSubview(newStory as UIView)

Everything is created properly and my view has a label which is placed with autoLayout.

Here's my autoLayout for the label: enter image description here

Right now, the UIScrollView remains empty (or at least looks blank). Is there something that I'm missing or not thinking about? Could my autoLayout be causing the problem?

Thanks

1

1 Answers

1
votes

InboxStory is a subclass of UIView? And titleLabel is a subview of it? But in Storyboard you placed it as a subview of a scrollview in. Then added the view newStory (with an opaque white background) on top of it so that it completely fills the scrollview. So you know what's happening try replacing

scrollView.addSubview(newStory as UIView)

With

scrollView.insertSubview(view:newStory, belowSubview: newStory.titleLabel)

You should add titleLabel as a subview of newStory then making that a subview of scrollView.