【问题标题】:MBProgress HUD not showing the correct mode always default modeMBProgress HUD 未显示正确模式始终默认模式
【发布时间】:2012-08-29 12:18:31
【问题描述】:

我正在尝试使用一种模式来初始化 MBProgress HUD,但仅使用标签而不是环形模式弹出进度。

    //Addition of new HUD progress whilst running the process field entries method
    HUD = [[MBProgressHUD alloc] initWithView:self.view];
    [self.view addSubview:HUD];

    // Set determinate mode
    HUD.mode = MBProgressHUDModeAnnularDeterminate;

    HUD.delegate = self;
    HUD.labelText = @"Signing you up";

    // myProgressTask uses the HUD instance to update progress
    [HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES];

我也在代理行收到警告。

Assigning to 'id<MBProgressHUDDelegate>' from incompatible type 'NewUserViewController *const __strong'

///

这是另一个例子 - HUD-test 是一个简单的应用程序,我设置它来显示完整的代码和问题(第二张图片) \\

///

【问题讨论】:

    标签: ios ios5 uiviewcontroller viewcontroller mbprogresshud


    【解决方案1】:

    为了摆脱警告,只需在头文件中将您的类定义为 MBProgressHUDDelegate。

    要注意正确的模式,请查看 MBProgressHUD.h 模式枚举:

    /** Progress is shown using an UIActivityIndicatorView. This is the default. */
    MBProgressHUDModeIndeterminate,
    /** Progress is shown using a round, pie-chart like, progress view. */
    MBProgressHUDModeDeterminate,
    /** Progress is shown using a ring-shaped progress view. */
    MBProgressHUDModeAnnularDeterminate,
    /** Shows a custom view */
    MBProgressHUDModeCustomView,
    /** Shows only labels */
    MBProgressHUDModeText
    

    选择您要显示的并使用此代码激活:

       MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 
        [HUD setMode: MBProgressHUDModeAnnularDeterminate]; 
        HUD.delegate = self; 
        HUD.labelText = @"Signing you up"; 
        [HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES];
    

    【讨论】:

    • 这取自 HUD 演示:code- (IBAction)showWIthLabelAnnularDeterminate:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; [self.navigationController.view addSubview:HUD]; // 设置确定模式 HUD.mode = MBProgressHUDModeAnnularDeterminate; HUD.delegate = 自我; HUD.labelText = @"加载中"; // myProgressTask 使用 HUD 实例更新进度 [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES]; code 在我的情况下,我没有使用导航控制器,只是一个 uiview
    • 为什么不使用“showHUDAddedTo:animated:”方法?它旨在将进度 HUD 添加到您的视图中。
    • 如果我将代码更改为以下内容:HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; [self.view addSubview:HUD]; // 设置确定模式 HUD.mode = MBProgressHUDModeAnnularDeterminate; HUD.delegate = 自我; HUD.labelText = @"注册你"; // myProgressTask 使用 HUD 实例更新进度 [HUD showWhileExecuting:@selector(processFieldEntries) onTarget:self withObject:nil animated:YES];同样的问题适用于它显示标题文本而不是实际的 HUD 模式...
    • 您仍然收到警告吗?
    • 是的,警告仍然出现。文本似乎不是问题,就像模式没有加载到 HUD。所以它默认回来了,它是只有文字的黑框,而不是我调用它之前设置的环形模式
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-07
    • 2021-06-30
    • 1970-01-01
    • 1970-01-01
    • 2021-03-15
    • 1970-01-01
    相关资源
    最近更新 更多