Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.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
如何添加子菜单';ios中的表视图中的_Ios_Uitableview_Custom Cell - Fatal编程技术网

如何添加子菜单';ios中的表视图中的

如何添加子菜单';ios中的表视图中的,ios,uitableview,custom-cell,Ios,Uitableview,Custom Cell,我不知道这个问题是否被问到,但我仍在寻找答案。我在tableview概念中工作,我正在创建一个表格视图,类似于一些菜单集,如收件箱、发送、设置等。现在我想要的是在每个菜单中创建子菜单,例如,如果我单击收件箱,它将显示“新建”,回复,删除了每个我想创建子菜单的主菜单。使用数组,我们可以通过检查部分加载,但不使用数组,我想直接创建一个值得注意的数组,我使用了自定义单元格,我还想按照菜单显示图像,如果是收件箱,我必须显示收件箱图像。有人能帮我吗 -(NSInteger)numberOfSect

我不知道这个问题是否被问到,但我仍在寻找答案。我在tableview概念中工作,我正在创建一个表格视图,类似于一些菜单集,如收件箱、发送、设置等。现在我想要的是在每个菜单中创建子菜单,例如,如果我单击收件箱,它将显示“新建”,回复,删除了每个我想创建子菜单的主菜单。使用数组,我们可以通过检查部分加载,但不使用数组,我想直接创建一个值得注意的数组,我使用了自定义单元格,我还想按照菜单显示图像,如果是收件箱,我必须显示收件箱图像。有人能帮我吗

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

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 8;

}

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

    static NSString *cellidentifier=@"ViewProfileCell";

    MyHomeViewCell *cell= [[MyHomeViewCell alloc] init];

    cell=(MyHomeViewCell*)[tableView dequeueReusableCellWithIdentifier:cellidentifier];

    if(!cell)
    {
NSArray *nibofMyHomeCell=[[NSBundle mainBundle]loadNibNamed:@"MyHomeViewCell" owner:self options:Nil];
        cell=[nibofMyHomeCell objectAtIndex:0];


    }

    if(indexPath.section==0)
    {
        cell.MyHomeMenuLabel.text=@"Inbox";
    }



}

有很多方法可以做到这一点。例如,您可以将每个项目显示为节标题,如果点击节标题,则显示(或隐藏)该节中的所有行。作为“子菜单”项的行(新建、回复、删除)。或者,您可以为每个零件使用不同的部分,以及如何使用或隐藏这些部分。或显示和隐藏行。这几乎都是通过更改节数和行数来控制的。

您可以创建一个UITableview,其中将包含您所说的收件箱、发送、设置等单元格

在您需要创建另一个UITableView后,它将包含您的子菜单按钮或标签,如“新建”、“回复”、“单击收件箱时删除”

同样,您将在主UITableView中对其余单元格执行此操作

不要混淆我将如何识别调用哪个tableview

您将检查tableview名称,如下所示:

 if(tableView==main)
    {
    ///Code for main menu tableview.
    }
    else if(tableView==sub)
    {
    ////Code for submenu tableview. 
    }
您将在所有UITableView委托和数据源方法中执行此操作:

 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

这里是一个好的图茨,它可以帮助您:


这是Oliver Letter编写的github很棒的代码。

在本地创建新的tableView将比处理自定义单元格更容易,您想创建什么样的自定义单元格?