基于苹果示例代码TVAnimationsGestures,在基于UITableView的手风琴视图中一次打开一个部分 [英] Keeping one section open at a time in UITableView based accordion view based on apple sample code TVAnimationsGestures

查看:137
本文介绍了基于苹果示例代码TVAnimationsGestures,在基于UITableView的手风琴视图中一次打开一个部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用基于UITableView的手风琴视图构建应用程序。此代码基于Apple示例代码,可在此处此处
在示例代码中,我正在尝试修复的问题就在那里,所以我知道这不是我介绍的内容。

I'm building an app with a UITableView-based accordion view. This code is based on Apple sample code which can be found here or here. In the sample code, the problem I'm trying to fix is there, so I know that it's not something that I introduced.

如果打开多个部分而未明确关闭前一部分,则可以同时打开多个部分。这可能导致崩溃,可以通过按下按钮1,2,3,1,1,3来复制。

If you open multiple sections without closing the previous one explicitly, multiple sections can be open at the same time. This can lead to a crash, which can be replicated by hitting buttons 1, 2, 3, 1, 1, 3.

在我的应用程序中,我正在尝试制作打开新部分时,上一部分关闭,标题中的按钮进入未选择状态,这样您一次只能打开一个部分并选择一个部分标题按钮。如果有人对此示例代码或使用tableview有任何经验,我很乐意纠正这一点,特别是因为它是Apple自己的代码中固有的问题

In my app, I am trying to make the previous section close and the button in the header go to an unselected state when a new section is opened, so that you can only ever have one section opened and one section header button selected at a time. If anyone has any experience with this sample code or this use of a tableview, I'd love to correct this, especially since it's a problem inherent in Apple's own code

推荐答案

永远不会设置APLSectionInfo的属性APLSectionHeaderView * headerView。
所以在tableView委托方法中设置 sectionInfo.headerView = sectionHeaderView

The property APLSectionHeaderView* headerView of APLSectionInfo is never set. So set sectionInfo.headerView = sectionHeaderView in tableView delegate method.

-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section {

    APLSectionHeaderView *sectionHeaderView = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionHeaderViewIdentifier];

    APLSectionInfo *sectionInfo = (self.sectionInfoArray)[section];

    sectionHeaderView.titleLabel.text = sectionInfo.play.name;
    sectionHeaderView.section = section;
    sectionHeaderView.delegate = self;
    sectionInfo.headerView = sectionHeaderView;
    return sectionHeaderView;
}

这篇关于基于苹果示例代码TVAnimationsGestures,在基于UITableView的手风琴视图中一次打开一个部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆