【发布时间】:2016-02-29 08:06:21
【问题描述】:
我刚刚开始 iOS 开发。我正在尝试从 NSArray 在 UItableview 中显示多个列?所以请帮助我吗?我已经创建了一列,但我不知道如何创建另一列?
我做了以下事情。
// This is my code
- (NSArray *)numbers
{
NSArray *col1 = @[@"1", @"2", @"3", @"4", @"5"];
return col1;
}
- (NSArray *)numberCodes
{
NSArray *col2 = @[@"Roy", @"Ankit", @"Jhon", @"Kem", @"Pawan"];
return col2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.numbers.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
//cell.textLabel.text = [self.numbers objectAtIndex:indexPath.row];
cell.textLabel.text = [self.numberCodes objectAtIndex:indexPath.row];
return cell;
}
【问题讨论】:
-
能不能把你试过的代码拿出来,很容易解决
-
请阅读how to ask good questions 并尝试编辑您的问题。有了高质量的问题,您将更快地获得更好的答案。谢谢!
-
另外,
UITableView不是行和列意义上的表格;就其本身而言,它只有一个“列”。
标签: ios objective-c uitableview xcode7