次のコードは、サンプル デモからのものです。
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
ビューとして .xibs を使用します。ストーリーボードを使用するアプリケーションを作成しています。したがって、HUD をインスタンス化するときの initWithView メソッド用の navigationController はありません。.xibs と navigationController を使用せずに HUD を実装する方法はありますか? 「self」と「self.view」の両方を渡そうとしましたが、うまくいきません。これが入っているクラスは ViewController.m クラスであり、UIViewController クラスです。だから、なぜ自分自身を渡すことがうまくいかないのかわかりません。
これは私のコードです
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
繰り返しますが、「自己」は私のメインViewControllerです
ありがとう!