I don't think I quite understand how to make an image appear on the screen using RubyMotion. All I'm attempting to do at the moment is to get a map of our campus to display on the screen. Here is the code I have right now for the particular view controller:
class MapDisplayController < UIViewController
def initWithNibName(name, bundle: bundle)
super
self
end
def viewDidLoad
self.title = "Campus Map"
# Initialize an image view with an image of the map from a file.
@map_view = UIImageView.alloc.initWithImage(UIImage.imageNamed('campus.jpg'))
@map_view.center = CGPointMake(self.view.frame.size.width / 2, self.view.frame.size.height / 2)
# Set some basic accessibility properties.
@map_view.accessibilityLabel = "RVH Campus Map"
@map_view.userInteractionEnabled = true
self.view.addSubview @map_view
end
end
The view itself loads OK other than the fact it's missing the picture. Am I misunderstanding how to initialize it? Is my init
function missing something? Should I be using viewDidAppear
instead?