故事板 iOS MBProgressHUD [英] Storyboard iOS MBProgressHUD
问题描述
我正在尝试在使用故事板的项目上设置 MBProgressHUD,当我尝试编译它时,我收到以下错误.然后当我点击我的按钮调用它时没有弹出窗口.关于我可以做些什么来解决这个问题的任何想法?
I am trying to setup MBProgressHUD on a project that uses storyboards, I am getting the errors below when ever I try to compile it. I then get no popup when I click on my button to call this. Any ideas on what i can do to fix this?
代码:
HUD = self.navigationController.view;
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
错误:
DetailViewController.m:162:24:{162:24-162:28}: 警告:通过'DetailViewController *const __strong' 到不兼容的参数输入id"[3]
DetailViewController.m:162:24:{162:24-162:28}: warning: passing 'DetailViewController *const __strong' to parameter of incompatible type 'id' [3]
DetailViewController.m:警告:语义问题:指针不兼容从UIView *"分配给MBProgressHUD *__strong"的类型
DetailViewController.m: warning: Semantic Issue: Incompatible pointer types assigning to 'MBProgressHUD *__strong' from 'UIView *'
推荐答案
我不明白你为什么要将 UIView
分配给(我假设是)MBProgressHUD
示例中第一行的变量.下面显示了 MBProgressHUD
的典型用法——这在 ARC 下对我有用(参考你的 上一个问题):
I don't understand why you're assigning a UIView
to (what I'm assuming is) an MBProgressHUD
variable on the first line of your example. The following shows typical usage of MBProgressHUD
—this works for me under ARC (referencing your previous question):
self.HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:self.HUD];
[self.HUD setDelegate:self];
[self.HUD setLabelText:@"Loading"];
[self.HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
这篇关于故事板 iOS MBProgressHUD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!