Storyboard iOS MBProgressHUD

﹥>﹥吖頭↗ 提交于 2020-01-03 04:26:05

问题


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?

Code:

    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];

Errors:

DetailViewController.m:162:24:{162:24-162:28}: warning: passing 'DetailViewController *const __strong' to parameter of incompatible type 'id' [3]

DetailViewController.m: warning: Semantic Issue: Incompatible pointer types assigning to 'MBProgressHUD *__strong' from 'UIView *'


回答1:


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];


来源:https://stackoverflow.com/questions/8290717/storyboard-ios-mbprogresshud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!