我創建了一個表格,它動態地創建了自定義的包含textField的單元格。當我運行程序時,我可以將文本輸入到textFields中。但是,在退出程序/切換到不同的viewController之前,我無法收集輸入到它們中的文本。你能否建議我應該怎麼做才能提取用戶輸入的文字。訪問嵌入單元格中的textField
我知道我可以使用下面的代碼訪問細胞...
for (int section = 1; section < [self.tableView numberOfSections]; section++) // section 0: profile picture
{
for(int row = 0; row < [self.tableView numberOfRowsInSection:section]; row++)
{
NSLog(@"section = %d, row = %d", section, row);
NSIndexPath *tempIndexPath = [NSIndexPath indexPathForRow:row inSection:section];
UITableViewCell *tempCell = [self tableView:self.tableView cellForRowAtIndexPath:tempIndexPath];
// NSLog(@"tempCell = %@", tempCell);
}
}
但我不能夠提取其中所含的文本。
我也提到:Accessing UITextField in a custom UITableViewCell。但我正在尋找更清潔的解決方案。
謝謝!
你有沒有試着與吸氣二傳手的文本框,在自定義單元格類使用@屬性,以及訪問這些使用tempcell .yourtextfield.text。 – josh