Md1079
Md1079

Reputation: 1360

UIScrollView not hiding content

I have a scrollView with a rectangular frame to display a set of subViews and page them, I would expect those other subViews to be hidden and only the current content displayed but instead I get all this overlap onto my screen.

enter image description here

if scrollViewHasBeenSetUp == false {
            var index = 0
            for event in eventList.events {
                let match = getMatchCell(event)
                match.frame = CGRect(x: index * Int(matchScrollView.frame.width), y: 0, width: Int(matchScrollView.frame.width), height: Int(matchScrollView.frame.height))
                matchScrollView.contentSize = CGSize(width: Int(match.frame.width) * eventList.events.count, height: 120)
                matchScrollView.addSubview(match)
                index++
                print("cell frame: \(match.frame)")
            }
            scrollViewHasBeenSetUp = true
        }

Using the visual inspector you can see the scrollViews frame has been set correctly but its content still isn't being hidden.

enter image description here

Upvotes: 1

Views: 192

Answers (1)

Lumialxk
Lumialxk

Reputation: 6369

Did you select clip subviews?

enter image description here

And I see your y is always 0,is it a vertical scroll view?

Upvotes: 2

Related Questions