如何在tabbarcontroller中添加MBProgressHUD

时间:2014-12-01 05:15:40

标签: ios

我有tabbarcontroller将在viewcontroller1中调用。当用户点击MBProgressHUD

时,我想实现tabbar(活动指标)
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    HomeVC =[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
    TaskVC=[self.storyboard instantiateViewControllerWithIdentifier:@"TaskNCViewController"];
    ShopVC=[self.storyboard instantiateViewControllerWithIdentifier:@"ShopNCViewController"];
    WalletVC=[self.storyboard instantiateViewControllerWithIdentifier:@"WalletNCViewController"];

    tabViewControllers = [[NSMutableArray alloc] init];
    [tabViewControllers addObject:HomeVC];
    [tabViewControllers addObject:TaskVC];
    [tabViewControllers addObject:ShopVC];
    [tabViewControllers addObject:WalletVC];

    [self setViewControllers:tabViewControllers];
    HomeVC.tabBarItem.title=@"Home";
    [HomeVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"home-active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"home.png"]];
    [HomeVC.tabBarItem setTitleTextAttributes:@{UITextAttributeFont:[UIFont boldSystemFontOfSize:10]} forState:UIControlStateNormal];

    TaskVC.tabBarItem.title=@"Task";
    [TaskVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"task-active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"task.png"]];
    [TaskVC.tabBarItem setTitleTextAttributes:@{UITextAttributeFont:[UIFont boldSystemFontOfSize:10]} forState:UIControlStateNormal];

    ShopVC.tabBarItem.title=@"Shop";
    [ShopVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"shop-active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"shop.png"]];
    [ShopVC.tabBarItem setTitleTextAttributes:@{UITextAttributeFont:[UIFont boldSystemFontOfSize:10]} forState:UIControlStateNormal];

    WalletVC.tabBarItem.title=@"Wallet";
    [WalletVC.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"wallet-active.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"wallet.png"]];
[WalletVC.tabBarItem setTitleTextAttributes:@{UITextAttributeFont:[UIFont boldSystemFontOfSize:10]} forState:UIControlStateNormal];

    //set the status bar to white
    [self setNeedsStatusBarAppearanceUpdate];

}

2 个答案:

答案 0 :(得分:1)

首先给代表打电话 你的头文件

#import" MBProgressHUD.h"

@interface ViewController : UIViewController<MBProgressHUDDelegate>

然后选择标签栏或您要显示活动的位置

MBProgressHUD *hud= [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;

如果要关闭活动视图

[hud hide:YES];

答案 1 :(得分:0)

中创建MBProgressHUD的对象
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController

并实施UITabBarControllerDelegate