上的此答案
所以我试图在xcode中找出我的注册页面的想法 - 类似的东西:http://weswilliams.me/wp-content/uploads/2011/06/IMG_2525-E1307910945329.PNG
无论如何,我都无法弄清楚他们用来实现此显示的对象。它看起来像一个按钮顶部的Textfield吗?如果是这样,我永远无法让文本字段坐在顶部,它总是落在按钮后面,从而使其变得不可见。
有任何提示或建议?
这不是按钮上的文本字段。实际上,它是表视图中的文本框。您必须执行以下操作:
- 在笔尖上欣赏表视图。
- 创建插座并设置委托和数据源。
- 然后将以下代码添加到您的.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
那是基本的分组uitableview。阅读Apple文档。上面也有很多教程。