为什么我的UIImageView没有出现在屏幕上?

时间:2013-11-05 19:02:10

标签: ios uiimageview rubymotion

我认为我不太明白如何使用RubyMotion在屏幕上显示图像。我现在要做的就是让我们的校园地图显示在屏幕上。以下是我现在对特定视图控制器的代码:

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

除了缺少图片之外,视图本身加载OK。我误解了如何初始化它吗?我的init函数丢失了吗?我应该使用viewDidAppear吗?

0 个答案:

没有答案