1
使用RubyMation編寫TableView我有下面的代碼。 dataSource是另一個類。以下代碼運行良好。iOS RubyMotion:具有實例變量的UITableView
但首先我沒有使用@dataSource的實例變量 - 只是一個局部變量。 該應用開始正常。但當我開始滾動應用程序崩潰。
那麼,爲什麼我必須使用實例變量?
TIA, JW
class FolderController < UIViewController
def viewDidLoad
super
self.title = "Folder"
@table = UITableView.alloc.initWithFrame(self.view.bounds)
self.view.addSubview @table
# fine
@dataSource = DatasourceFolder.new
@table.dataSource = @dataSource
# crashes when scrolling the tableview
# dataSource = DatasourceFolder.new
# @table.dataSource = dataSource
end
末