使用不同的 NSMutableArrays 加载 UITableView [英] Loading the UITableView with different NSMutableArrays

查看:42
本文介绍了使用不同的 NSMutableArrays 加载 UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,我有 4 个标签按钮.单击它们后,我有 4 个数组被填充.现在我需要将这些数组显示到同一个表中.根据按钮单击表中的内容应更改.这是怎么做到的?

I have, in my view 4 tab buttons. Upon clicking them i have 4 arrays getting populated. Now i need to display these array into the same table. depending on the button click the contents in the table should change. How can this be done?

推荐答案

添加 UITabBarControllerDelegate

add UITabBarControllerDelegate

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {  

switch (tabBarController.selectedIndex) {
    case 1:
        table_mutableArray=nil;
        [table_mutableArray addObjectsFromArray:tab1_array];

        break;
     case 2:
        table_mutableArray=nil;
        [table_mutableArray addObjectsFromArray:tab2_array];

        break;
     case 3:
        table_mutableArray=nil;
        [table_mutableArray addObjectsFromArray:tab3_array];

        break;
    default:
        table_mutableArray=nil;
        [table_mutableArray addObjectsFromArray:tab4_array];
        break;
}
[tableview reloadData];
}

这篇关于使用不同的 NSMutableArrays 加载 UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆