我使用的 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将崩溃。

不知道该怎么告诉你如何完成你想要做的事。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top