2011-06-28 49 views
2

我正在嘗試向表格單元格添加文本字段。任何人都可以請更正此代碼向表格單元格添加文本字段

aCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"UserIDCell"] autorelease]; 
        aCell.textLabel.text = @"User Name"; 
        aCell.selectionStyle = UITableViewCellSelectionStyleNone; 
        UITextField *user_ID_TextField1 = [[UITextField alloc] initWithFrame:CGRectZero]; 
        aCell.accessoryView = user_ID_TextField1; 
        [user_ID_TextField1 release]; 

感謝

回答

4

看看下面這個例子。

UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(110, 10, 185, 30)]; 
    textField.clearsOnBeginEditing = NO; 
    textField.textAlignment = UITextAlignmentRight; 
    textField.delegate = self; 
    [aCell.contentView addSubview:textField]; 

請記得在您的頭文件中添加UITextFieldDelegate

+0

感謝它的工作。 – pa12

相關問題