ProMotion屏幕滞后

时间:2015-01-23 12:19:22

标签: rubymotion rubymotion-promotion

我正在开发一个带有列车站列表的应用程序,当您从列表中选择一个站点时,应该有一个显示更多信息的视图。

对于我正在使用PM::TableScreen

的列表

在那里我有这个方法,当用户选择一个电台时会被调用:

def select_station(station)
  open StationScreen.alloc.initWithStation(station)
end

和相应的StationScreen

class StationScreen < UIViewController

  def initWithStation(station)
    init.tap do
      @station = station
    end
  end

  def loadView
    self.title = @station[:name]
    @layout = StationLayout.new
    self.view = @layout.view
  end

end

这会产生以下结果:

enter image description here

单击后退按钮时效果会很流畅。

现在,我想切换到ProMotion :: Screen

StationScreen变为:

class StationScreen < PM::Screen

  attr_accessor :station

  def on_load
    self.title = @station[:name]
    @layout = StationLayout.new
    self.view = @layout.view
  end

end

select_station方法:

def select_station(station)
  open StationScreen.new(station: station)
end

现在后面的动画非常奇怪。注意图像如何仍然显示一段时间,然后消失。

enter image description here

我做错了什么以及如何使用ProMotion::Screen正确实施?

更新1:这解决了这个问题。 ProMotion的例子是错误的建议。

def load_view
  self.title = @station[:name]
  @layout = StationLayout.new
  self.view = @layout.view
end

这是正确的方法吗?

1 个答案:

答案 0 :(得分:0)

经过一些实验,我发现了它。有多种方法可以解决它:

1)on_load。这里的关键是告诉布局根视图是什么。然后它可以正确地弄清楚如何正确地进行背景动画。如果你没有给它root,就像我在开始时做的那样 - 后面的动画可能会破坏。 (至少这是我理解的方式)。

def on_load
  @layout = StationLayout.new(root: self.view)
  @layout.build
end

2)load_view。在这里,出于某种原因,它没有指定根视图就可以正常工作。我猜它会在将self.view分配给布局视图时自动发生。

def load_view
  @layout = StationLayout.new
  self.view = @layout.view
end

我最终使用on_load