Customizing the More menu on a Tab bar

后端 未结 6 740
野性不改
野性不改 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:28

    @interface TabBarViewController () 
    
    @property (nonatomic,strong) UITableView* tabBarTableView;
    @property (nonatomic,weak) id  currentTableViewDelegate;
    
    @end
    
    @implementation TabBarViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        [self costumizeMoreTableView];
    
    }
    
    -(void)costumizeMoreTableView{
        _tabBarTableView = (UITableView *)self.moreNavigationController.topViewController.view;
        _currentTableViewDelegate = _tabBarTableView.delegate;
        _tabBarTableView.delegate = self;
        _tabBarTableView.dataSource = self;
        [_tabBarTableView registerNib:[UINib nibWithNibName:@"MoreTabBarTableViewCell" bundle:nil] forCellReuseIdentifier:@"MoreTabBarTableViewCell"];
    
    }
    
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        return 120;
    }
    
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
        return 2;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        MoreTabBarTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MoreTabBarTableViewCell" forIndexPath:indexPath];
        [cell setMoreTableValues];
        return cell;
    }
    
    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath{
          [_currentTableViewDelegate tableView:tableView didSelectRowAtIndexPath:indexPath];
     }
    
     @end
    

提交回复
热议问题