因此,我需要遍歷的UITableViewControllers的廣泛層次結構。每個人都需要它自己的自定義視圖控制器。我的任何特定tableview的數據源當前是一串字符串,如「A,B,C,D,E,F」。我didSelectRowAtIndexPath方法方法是一長串if語句,像這樣的(僞):UITableViewController的自定義類Datasource
if cell.text = "A"
alloc init AViewController
navigationController push aViewController
if cell.text = "B"
alloc init BViewController
navigationController push bViewController
我覺得這是凌亂。必須有一個更乾淨的方式來做到這一點。任何「最佳實踐」?我最好的想法是製作一個包含cellTitle和viewController類的自定義類。然後我可以使用這些數組作爲我的數據源,並做這種事情:
UITableViewController *newView = [custom.viewControllerClass alloc] init...
想法?