1

MBProgressHUD在加载数据时使用,用户可以在此过程中按下另一个选项卡按钮。MBProgressHUD只禁用视图内容。我检查了其他帖子,但没有看到任何可以帮助我禁用选项卡按钮的内容。

我试图设置tabbaritem.userInteractionEnabled为,NO但我找不到访问它的方法。我可以在情节提要中做到,但不能将其切换回YES.

我的问题是;从我的 viewController 有什么办法可以访问tabbarcontroller.tabbaritem.userInteractionEnabled吗?

4

2 回答 2

1

我使用类别:

UIViewController+MBProgressHUD.h

#import <UIKit/UIKit.h>

@class MBProgressHUD;

@interface UIViewController (MBProgressHUD)

- (MBProgressHUD *)showHUD;
- (MBProgressHUD *)showHUDFromTitle:(NSString *)title;
- (MBProgressHUD *)showHUDFromTitle:(NSString *)title completedImage:(BOOL)completedImage;
- (void)hideHUD;

@end

和 UIViewController+MBProgressHUD.m

#import "UIViewController+MBProgressHUD.h"
#import <MBProgressHUD/MBProgressHUD.h>

@implementation UIViewController (MBProgressHUD)

- (MBProgressHUD *)showHUDFromTitle:(NSString *)title {
    UIView *view;
    if (self.tabBarController.view != nil) {
        view = self.tabBarController.view;
    } else if (self.navigationController.view != nil) {
        view = self.navigationController.view;
    } else {
        view = self.view;
    }
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:NO];
    hud.labelText = title;
    return hud;
}

- (MBProgressHUD *)showHUD {
    return [self showHUDFromTitle:NSLocalizedString(@"Loading", @"Loading")];
}

- (MBProgressHUD *)showHUDFromTitle:(NSString *)title completedImage:(BOOL)completedImage {
    MBProgressHUD *hud = [self showHUDFromTitle:title];
    if (completedImage) {
        UIImage *checkmarkImage = [UIImage imageNamed:@"37x-Checkmark"];
        UIImageView *checkmarkImageView = [[UIImageView alloc] initWithImage:checkmarkImage];
        hud.customView = checkmarkImageView;
        hud.mode = MBProgressHUDModeCustomView;
    } else {
        hud.mode = MBProgressHUDModeText;
    }
    return hud;
}

- (void)hideHUD {
    [MBProgressHUD hideAllHUDsForView:self.tabBarController.view animated:NO];
    [MBProgressHUD hideAllHUDsForView:self.navigationController.view animated:NO];
    [MBProgressHUD hideAllHUDsForView:self.view animated:NO];
}

例子:

[self showHUD];
[self hideHUD];
于 2014-05-14T09:47:44.633 回答
0

这是一个简单的方法

 [[[self tabBarController] tabBar] setUserInteractionEnabled:NO];

如此链接所述: 如何在加载视图时隐藏标签栏操作?

适用于 MBProgressHUD

于 2013-06-29T21:10:23.993 回答