I have set up my scroll view in my ProMotion screen on_load
like this:
@scroll = add UIScrollView.alloc.initWithFrame(self.view.bounds)
i = 0
Card.all.each do |card|
label = UILabel.new
label.styleId = 'browse_detail'
label.text = card.name
label.setFrame [[ 0 + (i * 320), 0 ], [ 320, 568 ]]
add_to @scroll, label
i = i+1
end
@scroll.frame = self.view.bounds
@scroll.pagingEnabled = true
@scroll.scrollEnabled = true
@scroll.contentSize = self.view.bounds.size;
The first card displays as a big red box with the correct text and my repl tree shows all the cards:
0: . UIWindow(#d05c2f0, [[0.0, 0.0], [320.0, 568.0]])
1: `-- PXUIView_UIView(#9a4ba50, [[0.0, 0.0], [320.0, 568.0]])
2: `-- PXUIScrollView_UIScrollView(#9a4fe00, [[0.0, 0.0], [320.0, 568.0]])
3: +-- PXUILabel_UILabel(#9a4ca50, [[0.0, 0.0], [320.0, 568.0]], text: "Live in the Now. Now!...")
4: +-- PXUILabel_UILabel(#9a47c60, [[320.0, 0.0], [320.0, 568.0]], text: "I am a beutiful limit...")
5: +-- PXUILabel_UILabel(#9a46cf0, [[640.0, 0.0], [320.0, 568.0]], text: "Live in the Now. Now!...")
6: +-- PXUILabel_UILabel(#9a460b0, [[960.0, 0.0], [320.0, 568.0]], text: "Ruby Ruby Ruby!")
7: +-- PXUILabel_UILabel(#9a45210, [[1280.0, 0.0], [320.0, 568.0]], text: "BAm Bam")
8: +-- PXUIImageView_UIImageView(#9a4f0c0, [[0.0, 564.5], [320.0, 3.5]])
9: `-- PXUIImageView_UIImageView(#9a3e580, [[316.5, 0.0], [3.5, 568.0]])
However I can't scroll. What am I missing? There are many other questions with similar problems. Generally the solution for them was to set the contentSize
to a value less than the content width, but I think I have done that.
Since you know the exact content width (i * 320
) have you tried setting the content size to that?
@scroll.contentSize = [i * 320.0, 568.0]
Testing that properly pages multiple horizontal views for me.