私のコードで間違っては何ですか?私はMBProgressHUDを使用しています
-
26-09-2019 - |
質問
私が使用しているの MBProgress HUD を、私は問題が何であるかを知りません。
私はUIButton
を持っていることを示しての HUD の。
これは私のコードです:
- (void)showHUD:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.mode = MBProgressHUDModeCustomView;
[self.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"No Internet Connection...";
HUD.opacity = 0.7;
HUD.customView =
[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
[HUD showWhileExecuting:@selector(hudWasHidden)
onTarget:self
withObject:nil
animated:YES];
}
- (void)hudWasHidden {
float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep(50000);
}
}
ここでコンソールログがあります:
2010-06-11 17:55:26.255 Dual Search[14166:207] * -[MBProgressHUD setCustomView:]:
unrecognized selector sent to instance 0x6321220 2010-06-11 17:55:26.256 Dual
Search[14166:207] Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '** -[MBProgressHUD setCustomView:]:
unrecognized selector sent to instance 0x6321220' 2010-06-11 17:55:26.256 Dual
Search[14166:207] Stack: ( 41853515, 2505499913, 42125115, 41587990, 41584658,
13036, 2853830, 3324117, 3332879, 3328066, 2977128, 2871789, 2903111, 49860988,
41394236, 41390152, 49854621, 49854818, 2895329, 10508, 10362 )
UIButton
をクリックしたときに私のアプリは常にクラッシュします。
おかげ
解決
このココアコードに共通のクラッシュです:「認識できないセレクタは、」このような場合には非常に明示的です。 MBProgressHUDはcustomView
プロパティを持っており、それがクラッシュを引き起こしている設定しようとしません。 setCustomView
ここで呼び出される暗黙セレクタ(方法)であり、呼び出されたメソッドが存在しない場合のObjective-Cがクラッシュします。
わからないあなたが何をしようとして達成する方法をご紹介します。
所属していません StackOverflow