创建一个动态大小的 table

Create a dynamically sized table

我想创建一个动态列表,就像 Slack 中的列表一样,特别是频道,它会根据您所属的频道进行更新:

但是,我不知道从哪里开始。当我使用 SWRevealViewController Library, it only has a static table in the examples, not a dynamic one. While I'm working through this apple documentation 时,它仍然不是特定于与 SWRevealViewController 交互的,我更喜欢它,尽管我当然不介意非 SWRevealViewController 方法。我肯定会很感激一些提示,以朝着正确的方向前进!我所有的视图控制器现在都正确显示,所以我正在向它们添加信息。

有些相关:

Set UITableView Delegate and DataSource

UITableView issue when using separate delegate/dataSource

Creating A TableVIew Programmatically With Objective-C iOS

您可以使用本教程创建这样的菜单:

http://www.appcoda.com/ios-programming-sidebar-navigation-menu/

您只需将那些静态的 UITableViewController 替换为动态的即可。 您可能会很容易地找到如何创建动态。它的 body 将是这样的:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return menuItems.count;
}

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

    NSString *CellIdentifier = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    return cell;
}