我有一個包含UITextField的IB創建的UITableViewCell(帶有關聯的UITableViewCell子類,.m & .h)。此UITextField連接到UITableViewCell子類中的IBOutlet,並且還有一個屬性。在我的表視圖控制器我使用這個自定義單元格用下面的代碼:在自定義UITableViewCell中訪問UITextField
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"textfieldTableCell"];
if (cell == nil) {
// Create a temporary UIViewController to instantiate the custom cell.
UIViewController *temporaryController = [[UIViewController alloc] initWithNibName:@"TextfieldTableCell" bundle:nil];
// Grab a pointer to the custom cell.
cell = (TextfieldTableCell *)temporaryController.view;
// Release the temporary UIViewController.
[temporaryController release];
}
return cell;
}
的UITextField,顯示細膩並且點擊時,如預期的鍵盤彈出,但我如何獲得(得到的.text屬性)中的UITextField每行包含?以及如何處理UITextFields的'textFieldShouldReturn'方法?
乾杯Rog,我會嘗試一下,當我回到我的蘋果。我想知道Apple如何做到這一點,比如設置應用程序,我以爲我會比這更簡單/更清潔。我想他們可能會用完全不同的方式來做,而且都用代碼。 – Darthtong 2010-12-07 12:18:41