2013-03-30 43 views
0

我希望能在我的靜態細胞,使我使用StringInputTableViewCell類從這個演示一個TextField:https://github.com/wannabegeek/PickerTableViewCell/tree/master/PickerCellDemo與文本字段靜態細胞 - 連接類屬性的ViewController

我用故事板和我的故事板我有2個使用StringInputTableViewCell類的單元格。正如你可以看到有一個UITextField財產

@property (nonatomic, strong) UITextField *textField; 
StringInputTableViewCell.h

。在MyViewController的故事板上,我可以將標籤等連接到屬性,但我無法連接TextField,因爲它已添加到代碼中,並且TextField不在我的故事板上。所以我的問題是如何獲得MyViewController課程中的該房產?

回答

2

您可以將「StringInputTableViewCell」設置爲「MyViewController」中的一個屬性,或者如果您在「cellForRowAtIndexPath」期間嘗試填充該屬性,則可以通過標識符或標記訪問該屬性。

一旦你有一個指向你的表中顯示的「StringInputTableViewCell」對象的指針,你就可以直接在你的代碼中訪問它的「textField」屬性。

喜歡的東西:

StringInputTableViewCell * stringInputCell = (StringInputTableViewCell *) cell; 
if(stringInputCell) 
{ 
    stringInputCell.textField.text = @"Surprise, I can put text in here!"; 
} 
+0

因此,讓一個屬性MyViewController,然後這個屬性連接到電池? – Shinonuma

+0

你在表中使用這個StringInputTableViewCell嗎? –

+0

我有一個表視圖與2個表格視圖單元格 – Shinonuma