2015-12-21 95 views
1

我有MBProgressHUD实施到我的objective-c项目,而progressHUD启动我的应用程序崩溃。这是我的日志MBProgressHUD实施崩溃

0 CoreFoundation      0x0000000102b35f45 __exceptionPreprocess + 165 
1 libobjc.A.dylib      0x0000000101b08deb objc_exception_throw + 48 
2 CoreFoundation      0x0000000102b3e56d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 
3 CoreFoundation      0x0000000102a8beea ___forwarding___ + 970 
4 CoreFoundation      0x0000000102a8ba98 _CF_forwarding_prep_0 + 120 
5 EyeQueExam       0x0000000100e80762 -[MBProgressHUD launchExecution] + 82 
6 Foundation       0x0000000101792eab __NSThread__start__ + 1198 
7 libsystem_pthread.dylib    0x000000010568e05a _pthread_body + 131 
8 libsystem_pthread.dylib    0x000000010568dfd7 _pthread_body + 0 
9 libsystem_pthread.dylib    0x000000010568b3ed thread_start + 13 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

而且这行代码得到一个信号SIGABRT错误:

[targetForExecution performSelector:methodForExecution withObject:objectForExecution]; 

编辑:

// MBProgressHUD 
HUD = [[MBProgressHUD alloc] initWithView:self.view]; 
HUD.labelText = @"Uploading to Cloud..."; 
HUD.detailsLabelText = @"Just relax"; 
HUD.mode = MBProgressHUDModeAnnularDeterminate; 
[self.view addSubview:HUD]; 
[HUD show:YES]; 

[HUD showWhileExecuting:@selector(load) onTarget:self withObject:nil animated:YES]; 

-(NSArray*) load: (NSString *) componentName 
{ 
    float progress = 0.0; 

    while (progress < 1.0) { 
     progress += 0.01; 
     HUD.progress = progress; 
     usleep(50000); 
    } 
} 
+0

你能告诉你如何使用它?它以常见的方式在运行时崩溃。该对象不响应该选择器。 –

+0

如何使用MBProgressHUD? –

+0

刚刚更新了代码...使用了一些更多的代码。 – fafafa

回答

0

尝试编辑该代码:

[HUD showWhileExecuting:@selector(load) onTarget:self withObject:nil animated:YES]; 

要:

[HUD showWhileExecuting:@selector(load:) onTarget:self withObject:nil animated:YES]; 
+0

仍然得到相同的错误 – fafafa

+0

@fafafa ok。我会找到另一种方式。 –

+0

“HUD”变量如何?你在哪里定义它? –

0

变换load方法(void)

- (void) load { 
} 

您的代码:

- (void) load { 
{ 
    float progress = 0.0; 
    while (progress < 1.0) { 
     progress += 0.01; 
     HUD.progress = progress; 
     usleep(50000); 
    } 
}