我有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];
}
最佳答案
首先致电代表
您的头文件
#import“ MBProgressHUD.h”
@interface ViewController : UIViewController<MBProgressHUDDelegate>
然后选择选项卡或您要显示活动的位置
MBProgressHUD *hud= [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
如果要关闭活动视图
[hud hide:YES];
关于ios - 如何在TabbarController中添加MBProgressHUD,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27222096/