Iphone MBProgressHUD导致应用程序崩溃

Iphone MBProgressHUD导致应用程序崩溃,iphone,objective-c,ipad,Iphone,Objective C,Ipad,似乎使用MBProgressHUD导致了我的应用程序崩溃。在没有HUD代码的情况下,以下各项运行正常,但有了它,它就会崩溃: { ... HUD = [[MBProgressHUD alloc] initWithView:self.view]; // Add HUD to screen [self.view addSubview:HUD]; // Register for HUD callbacks so we can remove it from

似乎使用MBProgressHUD导致了我的应用程序崩溃。在没有HUD代码的情况下,以下各项运行正常,但有了它,它就会崩溃:

{

    ...

    HUD = [[MBProgressHUD alloc] initWithView:self.view];

    // Add HUD to screen
    [self.view addSubview:HUD];

    // Register for HUD callbacks so we can remove it from the window at the right time
    HUD.delegate = self;

    HUD.labelText = @"Connecting";

    // Show the HUD while the provided method executes in a new thread
    [HUD showWhileExecuting:@selector(runLocalNotificationHandler) onTarget:self withObject:nil animated:YES];  

[[self navigationController] popViewControllerAnimated:YES];
}

- (void) runLocalNotificationHandler
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

[self createLocalNotificationWithBug:[self tempBug]];

    [self performSelectorOnMainThread:@selector(finishedUpdatingNotifications) withObject:nil waitUntilDone:NO];

    [pool release];
}

- (void)finishedUpdatingNotifications
{

    [[self navigationController] popViewControllerAnimated:YES];
}

- (void)hudWasHidden {
    // Remove HUD from screen when the HUD was hidden
    [HUD removeFromSuperview];
    [HUD release];
}
生成以下调试输出:

gdb) continue
2010-07-02 00:07:55.224 Bugger[16796:207] >>> Entering -[HomeViewController viewDidAppear:] <<<
2010-07-02 00:07:55.225 Bugger[16796:207] <<< Leaving -[HomeViewController viewDidAppear:] >>>
2010-07-02 00:07:55.224 Bugger[16796:7007] <<< Leaving -[BugDetailViewController runLocalNotificationHandler] >>>
2010-07-02 00:07:55.226 Bugger[16796:207] >>> Entering -[BugDetailViewController prepareToolbar] <<<
2010-07-02 00:07:55.227 Bugger[16796:207] <<< Leaving -[BugDetailViewController prepareToolbar] >>>
2010-07-02 00:07:55.229 Bugger[16796:207] >>> Entering -[BugDetailViewController dealloc] <<<
[Switching to process 16796]
2010-07-02 00:07:55.260 Bugger[16796:207] <<< Leaving -[BugDetailViewController dealloc] >>>
[Switching to process 16796]
Program received signal:  “EXC_BAD_ACCESS”.
(gdb) 
如此接近

(gdb)
提示符处键入
bt
,然后发布回溯

除此之外,我的最佳猜测是,您的委托(上述代码中的
self
)正在被释放和释放,而没有首先作为委托从
MBProgressHUD
实例中删除。委托通常是一个弱引用,因此,正如您所描述的,它肯定会导致崩溃


哎哟。。。你的烟囱被踩了!我讨厌这种情况发生

回到最佳猜测;您的代理在作为代理从
MBProgressHUD
中删除之前是否已解除分配。。。您在代码上运行过“构建和分析”吗?

非常接近

(gdb)
提示符处键入
bt
,然后发布回溯

除此之外,我的最佳猜测是,您的委托(上述代码中的
self
)正在被释放和释放,而没有首先作为委托从
MBProgressHUD
实例中删除。委托通常是一个弱引用,因此,正如您所描述的,它肯定会导致崩溃


哎哟。。。你的烟囱被踩了!我讨厌这种情况发生


回到最佳猜测;您的代理在作为代理从
MBProgressHUD
中删除之前是否已解除分配。。。您在代码上运行过“构建和分析”吗?

我在MBProgress和navigationController的组合中遇到了类似的问题,由于某些原因,您无法通过选择器调用调用navigation controller操作,您必须仅在主线程中使用导航事件,希望这有帮助。

我在MBProgress和navigationController的组合中遇到了类似的问题,由于某些原因,您无法通过选择器调用来调用导航控制器操作,您必须仅在主线程中使用导航事件,希望这有帮助。

不,回溯不是很有用:程序接收到信号:“EXC_BAD_ACCESS”。[切换到进程23788](gdb)objc_msgSend()中的bt#0 0x029b4a93#1 0x00000000 in???(gdb)“构建和分析”没有给我这个文件任何有用的东西…所以我真的说不出来。据我所知,委托没有解除分配,但我真的说不出来,很明显。代码没有反映它应该是。不,回溯不是很有用:程序收到信号:“EXC\u BAD\u ACCESS”。[切换到进程23788](gdb)objc#U msgSend()中的bt#0 0x029b4a93#1 0x00000000 in???(gdb)“构建和分析”没有给我这个文件任何有用的东西…所以我真的说不出来。据我所知,委托没有解除分配,但我真的说不出来,很明显。代码没有反映它应该是。当我看到EXC_BAD_访问时,我会将NSZombieEnabled环境变量设置为YES and debug。当我看到EXC_BAD_访问时,我会将NSZombieEnabled设置为NSZombieEnabled将环境变量设置为YES和debug。
Program received signal:  “EXC_BAD_ACCESS”.
[Switching to process 23788]
(gdb) bt
#0  0x029b4a93 in objc_msgSend ()
#1  0x00000000 in ?? ()
(gdb)