开发者

UITextField inside UITableView cell

I have been reading through a lot of things trying to figure out what I am doing wrong. I have been trying to add 4 UITextFields inside of UITableView cells. I have the UITextFields created through IB, as well as the UITableView. I add the textfields to a NSMutableArray and then in the cellForRowAtIndexPath I am adding these text field object in the array. into 4 cells. However, this is where my issues arise. The text fields are not lined up in the table (img: http://cl.ly/5a02f3acdd44d8a08125). Here is some code:

viewDidLoad: textBoxList = [[NSMutableArray alloc] init];

[textBoxList addObject: txtName];
[textBoxList addObject: txtIP];
[textBoxList addObject: txtPort];
[textBoxList addObject: txtPassword];

cellForRowAtIndexPath: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithI开发者_运维问答dentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] init] autorelease];
}

// Set up the cell...
[cell.contentView addSubview: [textBoxList objectAtIndex:[indexPath row]]];


return cell;

}

Is this happening because I set these UITextFields up in IB and not creating them dynamically? Something with my delegates? Im lost....


You need to set the frame of the labels relative to the cell.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜