두 클래스가 있습니다. 하나는 ItemController
(확장 UITableViewController
)이고 다른 하나는 ItemCell
(확장 'UITableViewCell')입니다.UITableViewCell에서 새 컨트롤러를 푸는 방법
각 셀을 클릭하면 ItemController
의 didSelectRowAtIndexPath
에서 새 컨트롤러를 푸시합니다.
또한 ItemCell
에는 각 셀마다 다른 tag
의 작은 버튼 몇 개가 있습니다. 이 버튼 중 하나를 클릭하면 새 컨트롤러를 푸시하고 싶습니다. 어떻게해야합니까? 이 navigationController
이 없기 때문에 ItemCell
에서
self.navigationController.pushViewController
잘 너무 :
편집
이잖아, 내가 RubyMotion에서가 아닌 경우 솔루션을 참조하는 것을 선호 작동하지 않습니다나는 delegate
이 해결책 일 수 있다는 것을 읽었지만 그것을 구현하는 방법을 모르겠습니다.
def tableView(table_view, cellForRowAtIndexPath: index_path)
data_row = self.data[index_path.row]
cell = table_view.dequeueReusableCellWithIdentifier(CATEGORY_CELL_ID) || begin
rmq.create(ItemCell.initWithSomething(self), :category_cell, reuse_identifier: CATEGORY_CELL_ID).get
end
cell.update(data_row)
cell
end
ItemCell : 이것은 내가
ItemController의
한 일이다class ItemCell < UITableViewCell
attr_accessor :delegate
def initWithSomething(delegate)
@delegate = delegate
end
...use @delegate to push the new controller
end
을하지만 오류를 얻을
item_controller.rb : 114 :
tableView:cellForRowAtIndexPath:': undefined method
initWithSomething에 ' ItemCell의 경우 : 클래스 (NoMethodError)
물어보기 전에 뭔가를 시도해 보셨습니까? – javierfdezg
탐색 컨트롤러없이 새보기 컨트롤러를 "밀어 넣을"수 없습니다.presentViewController : animated : completion : – rdelmar
@ oski555 내가 시도한 방식으로 질문을 업데이트했습니다. – Anthony