ios - MBProgress HUD 没有显示正确的模式总是默认模式

标签 ios ios5 uiviewcontroller viewcontroller mbprogresshud

我正在尝试使用一种模式初始化 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];

我还在委托(delegate)行上收到警告。

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

///

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

///

最佳答案

为了消除警告,只需在头文件中将类定义为 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];

关于ios - MBProgress HUD 没有显示正确的模式总是默认模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12177777/

相关文章:

ios - 缩放 UIButton 动画 - Swift

ios - 为不同的 Controller 重用 View 的最佳方式

ios - 非标准导航设计

iOS 使用 UINavigationBar 删除输入到文本字段中的数据

ios - 如何将自定义 HTTP header 字段添加到 HLS 的 AVPlayer 请求

ios - 为另一个类添加目标

iphone - 当 Wi-Fi 和蜂窝网络都打开时,蜂窝网络的可达性返回 False

iphone - 用于 iOS 项目的 XMLRPC-iOS

ios - Tesseract 改进和图像预处理步骤

ios - 如何禁用 AVPlayerViewController 中的音频和字幕设置