gpt4 book ai didi

iphone - UITableView 单元格内的 UITextField

转载 作者:可可西里 更新时间:2023-11-01 05:48:22 25 4
gpt4 key购买 nike

我一直在阅读很多东西,试图找出我做错了什么。我一直在尝试在 UITableView 单元格中添加 4 个 UITextFields。我有通过 IB 创建的 UITextFields 以及 UITableView。我将文本字段添加到 NSMutableArray,然后在 cellForRowAtIndexPath 中我将这些文本字段对象添加到数组中。分成 4 个单元格。但是,这就是我的问题出现的地方。文本字段未在表中排列(img:http://cl.ly/5a02f3acdd44d8a08125)。这是一些代码:

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



[textBoxList addObject: txtName];
[文本框列表添加对象:txtIP];
[文本框列表添加对象:txtPort];
[文本框列表添加对象:txt密码];

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



static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(细胞==无){
cell = [[[UITableViewCell alloc] init] autorelease];
}

//设置单元格...
[cell.contentView addSubview: [textBoxList objectAtIndex:[indexPath row]]];


返回单元格;

}

发生这种情况是因为我在 IB 中设置了这些 UITextFields 而不是动态创建它们吗?我的代表有事吗?我迷路了....

最佳答案

您需要设置标签相对于单元格的框架。

关于iphone - UITableView 单元格内的 UITextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4030169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com