【问题标题】:Expand collapse UITableViewCell [duplicate]展开折叠 UITableViewCell [重复]
【发布时间】:2011-07-08 14:41:36
【问题描述】:

可能重复:
UITableView Cell expand on click

我在 UITableView 的 UITableViewCell 中需要帮助。我的要求如下:

查看转推、列表等 当我点击转发时出现以下

您可以看到转发扩展并在下面显示其他列表和列表以及更多幻灯片。 我想做同样的。 任何类型的帮助都非常感谢,教程链接或任何东西。 谢谢你

【问题讨论】:

    标签: iphone objective-c cocoa-touch uitableview


    【解决方案1】:

    我认为this applelink 可以帮助您,这是表格视图的绝佳示例

    【讨论】:

    • 你的链接和vin的链接是一样的,反正thanx
    • HVTableView: 具有展开/折叠功能的 UITableView
    【解决方案2】:

    我已经通过使用 tableview header 实现了一个类似的。

    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
        UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 32)];
        UIButton *sectionButton = [UIButton buttonWithType:UIButtonTypeCustom];
        sectionButton.tag = section;
        sectionButton.frame = customView.frame;
        [sectionButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    
        UILabel *titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 32)] autorelease];
        titleLabel.textAlignment = UITextAlignmentCenter;
        titleLabel.backgroundColor = [UIColor clearColor];
        titleLabel.font = [UIFont boldSystemFontOfSize:13];
        titleLabel.textColor = [UIColor whiteColor];
    
        NSString *tableHeader = @"table_header_down.png";
        switch (section) {
            case 0:
                titleLabel.text = @"Section1";
                tableHeader = showSection1 ? @"table_header_up.png" : @"table_header_down.png";
                break;
            case 1:
                titleLabel.text = @"Section2";
                tableHeader = showSection2 ? @"table_header_up.png" : @"table_header_down.png";
                break;
            case 2:
                titleLabel.text = @"Section3";
                tableHeader = showSection3 ? @"table_header_up.png" : @"table_header_down.png";
                break;
            case 3:
                titleLabel.text = @"Section4";
                tableHeader = showSection4 ? @"table_header_up.png" : @"table_header_down.png";
                break;
            default:
                break;
        }
        [sectionButton setImage:[UIImage imageNamed:tableHeader] forState:UIControlStateNormal];
        [customView addSubview:sectionButton];
    
        [customView addSubview:titleLabel];
    
        return [customView autorelease];
    }
    

    然后我根据每个部分对应的布尔值加载单元格,如果Bool 0,则行数返回0,并在Bool 1时返回计数。

    【讨论】:

    • 我现在迟到了,但明天一定会检查你的解决方案,thanx
    • 另外,我忘了提一件事,如果在节方法中的行,你可能需要在数量上做更多的事情。如果对应于该部分的布尔变量为零,则返回零。在按下按钮的方法中,我在 0 和 1 之间切换部分的标志。
    【解决方案3】:

    您还可以找到来自 Apple 的 this 示例代码,很有帮助。

    【讨论】:

    • 我查看了您的链接,是的,这几乎是我想要的,但它是一个大型程序,所以我正在寻找替代方案,如果没有找到任何东西,肯定会同意您的想法。非常感谢,真的很感激
    • @Kshitizyou 也可以通过使用自定义单元格轻松实现该功能,但我的经验表明,您通过这种方法获得的流畅体验是那种方法无法实现的。
    • 感谢您的帐户,再次感谢您
    • 你回答是被接受的人,至少我有地方开始并且有我想要的,我不知道其他人在做什么
    【解决方案4】:

    如果您是 Apple 开发人员,请前往 WWDC 视频并查看高级 TableView 视频。它描述了如何完全按照您的要求进行操作。

    【讨论】:

    • 你能给我链接吗?是的,我是苹果开发者
    • developer.apple.com/itunes/… 进入后,转到应用程序框架,然后转到视频 28,掌握 TableView
    猜你喜欢
    • 1970-01-01
    • 2018-05-16
    • 2014-07-20
    • 1970-01-01
    • 2011-08-05
    • 1970-01-01
    • 2020-10-03
    • 1970-01-01
    • 2020-08-30
    相关资源
    最近更新 更多