2014-01-29 32 views
1

我使用UINavigationController作爲rootviewController和storyboard segue的pushingViewController。我的應用程序中有許多視圖控制器。我只使用推視圖控制器來傳遞它們。iOS崩潰:respondsToSelector:發送到已釋放實例的消息

崩潰的場景:(可重現)

  1. 我有一個產品列表的viewController,我將導航到產品細節的viewController,當我在使用自來水手勢識別器的列表上的產品挖掘。
  2. 從詳細視圖控制器中,我將被推送到購物車項目viewController,當我點擊一個名爲「添加到購物車」的按鈕時,它顯示所有選定的產品。
  3. 如果我嘗試爲所有產品付款,我想從人員選擇器中選擇一個聯繫人,當我按下付款按鈕時,它會顯示peopelpickerController爲modalViewController,當我選擇聯繫人時,它會崩潰。
  4. 僅當從產品列表視圖控制器到人員控制器來回移動時,纔會發生崩潰。當我使用儀器進行調試時,我得到了崩潰,說已解除分配的實例接收消息。
    我已經包含了我遇到崩潰的方法。但我從來沒有試圖從任何控制器調用該方法。

代碼...

//choosing contact and people picker delegate 
- (IBAction) chooseContacts: (id) sender { 
    picker = [ 
     [ABPeoplePickerNavigationController alloc] init]; 
    picker.peoplePickerDelegate = self; 
    [self presentViewController: picker animated: YES completion: nil]; 
} 

#pragma mark - Addressbook delegate methods 

- (void) peoplePickerNavigationControllerDidCancel: (ABPeoplePickerNavigationController *) peoplePicker { 
    [self dismissViewControllerAnimated: YES completion: nil]; 
} 


- (BOOL) peoplePickerNavigationController: (ABPeoplePickerNavigationController *) peoplePicker 
shouldContinueAfterSelectingPerson: (ABRecordRef) person { 
    [self dismissViewControllerAnimated: YES completion:^{ 
     [self displayPerson: person]; 
    }]; 

    return NO; 
} 

崩潰在線路performSegueWithIdentifier下面的方法時,

#pragma mark- Tap gesture delegates 

-(void)tapGestureFirstImage:(UITapGestureRecognizer *)sender 
{ 
    UIImageView *image = (UIImageView *)sender.view; 
    if (image.tag < [_productsArray count]) { 
      [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 
     productDetailDictionary = [_productsArray objectAtIndex:image.tag]; 
     NSLog(@"%@",productDetailDictionary); 
     [self performSegueWithIdentifier:@"productDetailSeague" sender:sender]; 
    } 
    NSLog(@"imageView.Tag %ld",(long)image.tag); 

} 

崩潰日誌:

Exception Type: EXC_CRASH (SIGABRT) 
Exception Codes: 0x0000000000000000, 0x0000000000000000 
Triggered by Thread: 0 

Thread 0 Crashed: 
0 libsystem_kernel.dylib   0x39cb11fc __pthread_kill + 8 
1 libsystem_pthread.dylib   0x39d1aa2e pthread_kill + 54 
2 libsystem_c.dylib    0x39c61ff8 abort + 72 
3 libc++abi.dylib     0x38f90cd2 abort_message + 70 
4 libc++abi.dylib     0x38fa96e0 default_terminate_handler() + 248 
5 libobjc.A.dylib     0x396f291e _objc_terminate() + 190 
6 libc++abi.dylib     0x38fa71c4 std::__terminate(void (*)()) + 76 
7 libc++abi.dylib     0x38fa6a18 __cxa_throw + 112 
8 libobjc.A.dylib     0x396f277e objc_exception_throw + 246 
9 CoreFoundation     0x2ef5be88 +[NSException raise:format:] + 100 
10 UIKit       0x317b9590 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 496 
11 UIKit       0x317b7dce -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2054 
12 UIKit       0x317b6e20 -[UIViewController presentViewController:withTransition:completion:] + 4664 
13 UIKit       0x31992cae -[UIViewController presentModalViewController:animated:] + 26 
14 DHCC Events      0x0008f0c0 0x38000 + 356544 
15 libdispatch.dylib    0x39bd5d18 _dispatch_call_block_and_release + 8 
16 libdispatch.dylib    0x39bdbd16 _dispatch_after_timer_callback$VARIANT$mp + 46 
17 libdispatch.dylib    0x39bd5d04 _dispatch_client_callout + 20 
18 libdispatch.dylib    0x39bde7fe _dispatch_source_invoke$VARIANT$mp + 258 
19 libdispatch.dylib    0x39bdc73a _dispatch_main_queue_callback_4CF$VARIANT$mp + 186 
20 CoreFoundation     0x2ef26814 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4 
21 CoreFoundation     0x2ef250e8 __CFRunLoopRun + 1296 
22 CoreFoundation     0x2ee8fc22 CFRunLoopRunSpecific + 518 
23 CoreFoundation     0x2ee8fa06 CFRunLoopRunInMode + 102 
24 GraphicsServices    0x33b8327e GSEventRunModal + 134 
25 UIKit       0x31733044 UIApplicationMain + 1132 
26 DHCC Events      0x00041ad6 0x38000 + 39638 
27 libdyld.dylib     0x39bfaab4 start + 0 

感謝您的幫助。

+3

你能告訴崩潰。 – Fogmeister

回答

0

-(void)tapGestureFirstImage:(UITapGestureRecognizer *)sender

你執行與

[self performSegueWithIdentifier:@"productDetailSeague" sender:sender];

的SEGUE但我認爲發送方應該是self,而不是sender ..

UPDATE

你嘗試執行米賽格,而picker已激活?在這種情況下self可以被釋放,所以你可以嘗試執行賽格瑞picker被駁回後:

[picker dismissViewControllerAnimated:YES completion:^{[self performSegueWithIdentifier:@"productDetailSeague" sender:self];}]; 
+0

我在想可能是一樣的。甚至沒有'nil'。 – Fogmeister

+0

我會試試這個,讓你知道。 – Logunath

+0

@Logunath你真的需要把崩潰日誌放在你的問題中。沒有它,我們都只是猜測! – Fogmeister

相關問題