Ios 在Xcode中的分组表视图中添加节

Ios 在Xcode中的分组表视图中添加节,ios,xcode,tableview,Ios,Xcode,Tableview,我的代码与其他代码有点不同,但它是有效的 我是新的应用程序编码,但我想添加一些 这些文件分为几节: 所以他们中的一些人有自己的小组,每个小组都有一个小标题 但我的代码如下所示: 我不知道该插入什么来做正确的事情 (该图片的下半部分是详细视图中的图片,当您从表视图中选择某个内容时,该图片将显示在详细视图中。) (我知道Xcode在我的代码中显示了错误,但它仍然有效。) 有人能帮我吗?您必须实现一些UITableView方法和委托方法(当然还要将您的类设置为该类的委托): 有了它,您可以根据需要

我的代码与其他代码有点不同,但它是有效的

我是新的应用程序编码,但我想添加一些 这些文件分为几节:

所以他们中的一些人有自己的小组,每个小组都有一个小标题

但我的代码如下所示:

我不知道该插入什么来做正确的事情

(该图片的下半部分是详细视图中的图片,当您从表视图中选择某个内容时,该图片将显示在详细视图中。)

(我知道Xcode在我的代码中显示了错误,但它仍然有效。)


有人能帮我吗?

您必须实现一些UITableView方法和委托方法(当然还要将您的类设置为该类的委托):


有了它,您可以根据需要排列数据:每个部分一个数组,一个带有子数组的大数组。。。随你的便。只要您能从上述方法返回所需的值,Antthing就可以了。

谢谢!我得到了标题,但是现在标题下没有数据了?截图:@user1036372:给我你的tableView代码,我来看看。这应该是B,因为ROWSINSECTION返回的行数错误,或者ROWATINDEXPATH解析的单元格错误
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    //Here you must return the number of sectiosn you want
 }

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //Here, for each section, you must return the number of rows it will contain
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
     //For each section, you must return here it's label
     if(section == 0) return @"header 1"; 
     .....
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    // Set up the cell...
    cell.text = // some to display in the cell represented by indexPath.section and indexPath.row;

    return cell;
}