1

所以我试图在 xCode 中为我的注册页面找出想法——如下所示:http ://weswilliams.me/wp-content/uploads/2011/06/IMG_2525-e1307910945329.png

无论如何,我无法弄清楚他们使用什么对象来实现这种显示。它看起来像按钮顶部的 TextField?如果是这样,我永远无法让文本字段位于顶部,它总是落在按钮后面,从而使其不可见。

有什么提示或建议吗?

4

2 回答 2

0

这是一个基本的分组 UITableView。阅读 Apple 文档。也有大量的教程。

于 2012-11-01T21:07:34.337 回答
0

这不是按钮上的文本字段。实际上它是表格视图中的文本框。您必须执行以下操作:

  1. 在笔尖上进行表格视图。
  2. 创建插座并设置委托和数据源。
  3. 然后将以下代码添加到您的 .m 文件中。

试试这个

在此之前设置表格视图的行数。

- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"];
    if( cell == nil)
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease];   

    cell.textLabel.text = [[NSArray arrayWithObjects:@"First",@"Second",@"Third",@"Forth",@"Fifth",@"Sixth",@"Seventh",@"Eighth",@"Nineth",@"Tenth",nil] 
                           objectAtIndex:indexPath.row];

    if (indexPath.row % 2) {
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 21)];
        textField.placeholder = @"Enter Text";
        textField.text = [inputTexts objectAtIndex:indexPath.row/2];
        textField.tag = indexPath.row/2;
        textField.delegate = self;
        cell.accessoryView = textField;
        [textField release];
    } else
        cell.accessoryView = nil;

    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;        
}

或者你可以看到这个链接在 SO 上看到这个答案

于 2012-11-01T21:09:48.873 回答