[英]iPhone Populating Table With UITextFields
可以用UITextField类型填充表格吗? 如果是这样,怎么办?
我尝试了几种不同的实现,尽管每种都失败了。 请让我知道您过去是否取得了类似的成就以及您如何取得的成就。
你可以尝试一下MonoTouch.Dialog
创建一个自定义UITableViewCell
在tableViewController的viewDidLoad中注册它:
[self.tableView registerClass:[TableCell class] forCellReuseIdentifier:@"tableCell"];
确保tableView:cellForRowAtIndexPath:看起来像这样:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"tableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
在自定义单元格的initWithStyle:reuseIdentifier中:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
[self.contentView setBackgroundColor:[UIColor redColor]];
UITextField *textField= [[UITextField alloc] initWithFrame:CGRectMake(10, 0, 600, self.bounds.size.height)];
[textField setBackgroundColor:[UIColor greenColor]];
[self addSubview:textField];
}
return self;
}
需要调整textField的大小,自动换行和许多其他实用位来使输入和输出正常工作,但这会将textField放入tableViewCell中。
希望能有所帮助,史蒂夫
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.