Customizing the More menu on a Tab bar

后端 未结 6 743
野性不改
野性不改 2020-11-27 11:58

I am using a tab bar (UITabBarController) on my app and I wish to customize the appearance of the table that appears when you click the more button. I have worked out how to

6条回答
  •  隐瞒了意图╮
    2020-11-27 12:34

    visibleCells is populated only after the moreNavigationController is displayed.

    And the cells are created at runtime, so even if you change the content of the cells, they are replaced when they are displayed.

    One thing to try would be to replace the datasource of the moreNavigationController tableView, call the cellForRowAtIndexPath of the original datasource and change its content before returning it.

    Using the code below, after having displayed once the moreNavigationController to initialize it, you'll see that when you return to the moreNavigationController, the cells are red, but return immediately to white background.

    UITableView *view = (UITableView *)self.tabBarController.moreNavigationController.topViewController.view;
    if ([[view subviews] count]) {
      for (UITableViewCell *cell in [view visibleCells]) {
        cell.backgroundColor = [UIColor redColor];
      }
    }
    

提交回复
热议问题