我有一个数组,我想在UITable中保存它,但它不可见,我的代码是
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [myArrayNew count];
}
// 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:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSString *cellValue = [myArrayNew objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
这个数组有一些其他数组,而不是单个对象,
答案 0 :(得分:0)
然后你应该采用不同的编码,
[myArrayNew objectAtIndex:indexPath.row];
将返回一个对象数组,而不是字符串。
修改强>
您可以使用分区的tableview来显示数组数组。
所以代码如下,
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return [myArrayNew count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [[myArrayNew objectAtIndex:section]count];
}
// 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:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSString *cellValue = [[myArrayNew objectAtIndex:section]objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
答案 1 :(得分:0)
@Verer使用类似这样的东西
NSArray *cellArray = [myArrayNew objectAtIndex:indexPath.row];
NSString *cellValue = [cellArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
或类似的东西。如果您向我们展示myArrayNew中的内容类型,那么我们可以为您提供更多帮助。
编辑:这只是一个例子而不是实际答案。
答案 2 :(得分:0)
你必须将值存储在另一个数组中......以及你可以分配给字符串的第二个数组对象..