2012-03-15 32 views
0

我要做一個TableView佈局,但取決於選擇我想設置變量爲特定的數字。TableView:基於rowName設置變量

例子:

選擇 「ROW1」 - >阿爾法= 1.00

選擇 「2行」 - >阿爾法= 2.00 &測試版= 3.00 等等...

至於我關心的只是轉向下一個視圖,我希望我所有的行都鏈接到相同的視圖,但具有不同的/自定義Alpha和Beta。

嘗試搜索,但發現它很難在xcode中制定這個詞。

回答

0

所以你要去一個新的viewController,當在一個連接點擊?比尋找你的代碼在

tableView: didSelectRowAtIndexPath: 

在代碼中你會發現smth。這樣的:

ViewControllerClass* viewController = [[ViewControllerClass alloc] init]; 
[self.navigationController pushViewController: viewController animated: YES]; 
[viewController release]; 

只需添加您的自定義設置,前推:

ViewControllerClass* viewController = [[ViewControllerClass alloc] init]; 

if(indexPath.row == 0) 
{ 
    viewController.alpha = ...; 
    viewController.beta = ...; 
} 
else if(indexPath.row == 1) 
{ 
    viewController.alpha = ...; 
    viewController.beta = ...; 
} 
else 
{ 
    viewController.alpha = ...; 
    viewController.beta = ...; 
} 


[self.navigationController pushViewController: viewController animated: YES]; 
[viewController release]; 
+0

感謝那麼容易,因爲那個=) 但是我困惑如何才能訪問它宣佈阿爾法。 「Property」Alpha「not object on object type ...」 – Br8k 2012-03-15 18:02:25

+0

.. and btw「ARC禁止'發佈'的顯式消息發送」 – Br8k 2012-03-15 18:52:01

+0

無法弄清楚這一點!我不應該有** TableView viewController的某處嗎?我想爲一個UITableViewController(例如myTableVC)的TableView和一個UIViewController(例如myVC)我指向的viewController,當你點擊任何你沒有寫的行 – Br8k 2012-03-15 21:57:51