Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c UITableview仅打印NSMutableArray的第一个对象IOS_Objective C_Ios_Uitableview_Nsmutablearray - Fatal编程技术网

Objective c UITableview仅打印NSMutableArray的第一个对象IOS

Objective c UITableview仅打印NSMutableArray的第一个对象IOS,objective-c,ios,uitableview,nsmutablearray,Objective C,Ios,Uitableview,Nsmutablearray,我有一个NSMutableArray和一个从NSMutableArray填充的分组表视图 当我打印带有NSLog输出的NSmutableArray时 “String1”、“String2”、“String3” 但在UITableView单元格中,我总是看到NSMUtableArray的第一项: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of secti

我有一个NSMutableArray和一个从NSMutableArray填充的分组表视图

当我打印带有NSLog输出的NSmutableArray时
“String1”、“String2”、“String3”

但在UITableView单元格中,我总是看到NSMUtableArray的第一项:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    // Return the number of sections.
    return [_presenterList count];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    NSLog(@"_presenterList objectAtIndex: %@",[_presenterList objectAtIndex:indexPath.row]);

    cell.textLabel.text=[_presenterList objectAtIndex:indexPath.row];
return cell;
}
输出NSlog
“String1”

tableview上的输出

String1
String1
String1
我做错了什么

添加编辑屏幕截图

我从字符串和1行tableview创建了一些标题,如图所示

cell.textLabel.text=[_presenterList objectAtIndex:indexPath.section];

而不是
cell.textlab.text=[\u presenterList objectAtIndex:indexPath.row]

而不是
cell.textlab.text=[\u presenterList objectAtIndex:indexPath.row]

您在
numberofrowsinssection
中返回“1”,在
numberofsectionsintable视图中返回
[array count]
。这是向后的(除非您真的希望数组中的每个项都有一个节)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_presenterList count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
您在
numberofrowsinssection
中返回“1”,在
numberOfSectionsInTableView
中返回
[array count]
。这是向后的(除非您确实希望数组中的每个项目都有一个节)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_presenterList count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

如果您要将此更新发布到
表格视图:numberOfRowsInSection:
您还应该将所需更新发布到
numberOfSectionsInTableView:
@NSPostWhenId我需要正好一个等于NSMutableArray count的行和节计数,请参见编辑问题的屏幕截图,因此您的答案为我提供了1个节and行等于NSMUTABLETCOUNT,与I行正好相反need@MordFustang如果这是您真正想要采用的设计,请查看下面的答案。如果您要将此更新发布到
表格视图:numberOfRowsInSection:
您还应该将所需更新发布到
numberOfSectionsInTableView:
@nsPostWhenIde我需要正好一行和一节的计数等于NSMutableArray计数,请参见编辑问题的屏幕截图,因此您的答案给我1行和一节的计数等于NSmutablecount,这与我的回答正好相反need@MordFustang如果这是你真正想要的设计,看看下面的答案。