Search code examples
uiscrollviewrubymotion

UIScrollView doesn't scroll with RubyMotion


I have a test application that I am trying to get the UIView to scroll and also move up when the keyboard comes on the screen. When I put the following code in and try to run the scroll through the simulator my UIScroll isn't working.

@scrollwindow = UIScrollView.alloc.initWithFrame(CGRect.new([0,0],[700,800]))
@scrollwindow.scrollEnabled = true
@scrollwindow.delegate
@window.addSubview(@scrollwindow)

@frame1 = UIView.alloc.initWithFrame(CGRect.new([10,10], [400, 200]))
@frame1.backgroundColor = UIColor.redColor
@scrollwindow.addSubview(@frame1)

@frame2 = UIView.alloc.initWithFrame(CGRect.new([20, 400], [600,700]))
@frame2.backgroundColor = UIColor.greenColor
@scrollwindow.addSubview(@frame2)

I am familiar with my understanding of Ruby but new to RubyMotion and the Objective-C community. Any help would be greatly appreciated.


Solution

  • You need to set the contentSize of the scroll view.

    http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html