按日期条件对 UItableView 部分进行排序

发布于 2024-12-14 14:34:50 字数 522 浏览 4 评论 0原文

将 myArray (NSMutableArray) 作为带有事件的 dataSource

自定义表部分是:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{
    customSections = [[NSMutableArray alloc] init];

    //My custom sections
    [customSections addObject:@"now"];
    [customSections addObject:@"in this day"];

    NSString *sectionText = [customSections objectAtIndex:section];
    return sectionText;   
}

缩短它们的最佳实践是什么? 对于每个事件,我都有一个开始时间和结束时间

Having myArray (NSMutableArray) as dataSource with events

And the custom table sections are:

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{
    customSections = [[NSMutableArray alloc] init];

    //My custom sections
    [customSections addObject:@"now"];
    [customSections addObject:@"in this day"];

    NSString *sectionText = [customSections objectAtIndex:section];
    return sectionText;   
}

What's the best practice to short them?
for each event I have a start time and end time

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素食主义者 2024-12-21 14:34:50

您应该在另一个地方初始化并填充您的 customSections 数组(例如,当您初始化此类时)。比你必须做这样的事情:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [customSections count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [customSections objectAtIndex:section];
}

You should initialize and fill in your customSections array somewhere in another place (for example when you initializing this class). Than you have to do something like this:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [customSections count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return [customSections objectAtIndex:section];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文