2014-02-21 39 views
0

這裏我與pushController一個問題,因爲我想用噠,我的子類,這樣navigationController.pushViewController該方法返回undefined

class cellEmpty < cell 

    @button_help.when(UIControlEventTouchUpInside) do 
     push RecommendationController.alloc.init 
    end 

def push(controller) 
    navigationController.pushViewController(controller, animated:true) 
    end 
end 

在這裏的錯誤:

undefined local variable or method `navigationController' 

但我,所以我認爲它一定是我在一個子類中使用它。 但如何使用它

預先感謝您

回答

0

你得到這個錯誤,因爲該方法正在從UICell中調用。您需要從您的視圖控制器調用此方法才能訪問navigationController。

如果你使用一個UITableViewController看看這個方法:

tableView(tableView, didSelectRowAtIndexPath: indexPath) 

從那裏,你可以決定什麼時候有人細胞水龍頭做什麼。