我是Xcode和Objective C的新手,但我似乎无法在我想创建的简单表上找到教程.我想要一个只有三行但两列的表(分组样式).A列有一个标签(如'Name:'),B列有实际数据("Jason").
我似乎无法找到如何做到这一点.除非我只是完全查找错误的东西?希望有人可以帮助我如何做到这一点或指出我正确的方向.
谢谢!!
您不想使用包含2列的表.它们不在iOS中使用.
你应该使用UITableViewCell一个UITableViewCellStyleValue2风格.而你要设置@"Name"为textLabel.text和@"Jason"作为detailTextLabel.text.

你必须tableView:cellForRowAtIndexPath:稍微改变一下.
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Name";
cell.detailTextLabel.text = @"Jason";
return cell;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11852 次 |
| 最近记录: |