开发者

Adding textfield to table cell

开发者 https://www.devze.com 2023-03-16 03:59 出处:网络
I am trying to add a textfield to a table cell. Can anyone please correct this code aCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@\"UserIDCell\"] autorelease];

I am trying to add a textfield to a table cell. Can anyone please correct this code

aCell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"UserIDCell"] autorelease];
                    aCell.textLabel.text = @"User Name";
                    aCell.selectionStyle = UITableViewCellSelectionStyleNone;
                    UITextField *user_ID_TextField1 = [[UITextField alloc] initWith开发者_Python百科Frame:CGRectZero];
                    aCell.accessoryView = user_ID_TextField1;
                    [user_ID_TextField1 release];

Thanks


Look at this example.

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

Remember to add UITextFieldDelegate to your header file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号