UINavigation Controller在显示ViewController时崩溃

时间:2014-06-15 11:52:18

标签: ios objective-c uinavigationcontroller

我有一个UINavigationController,其中有一个带有UITableView的MainViewController和一个ToolBar按钮。选择UITableViewCell将推送到SecondViewController并点击工具栏按钮将推送到ThirdViewController,两者都使用StoryBoard segue。 两个ViewControllers都是第一次推送OK,但是当UINavigationController先推送SecondViewController并弹回MainViewController时,推ThirdViewController会导致应用崩溃。所以我认为ThirdViewController's代码有些问题,但错误信息是:

SecondViewController respondsToSelector:]: message sent to deallocated instance 0x115621d0

奇怪的是,当我推动SecondViewController时,为什么ThirdViewController出现在错误消息中? 我将断点与prepareForSegue MainViewController一起调用而没有错误,viewDidLoad ThirdViewController之后被调用而没有错误,但当我在viewDidLoad结束时点击继续{1}}应用崩溃了。 使用带僵尸的乐器启用显示: Instruments

我正在推ThirdViewController,为什么代码会进入SecontViewController segue?我无法知道代码有什么问题?我正在使用ARC,所以我没有错误地发布任何内容。

SB:

的屏幕截图

所有三个视图控制器的类定义

// MainViewController.h
@interface MainViewController : UITableViewController <UIAlertViewDelegate, UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, MFMailComposeViewControllerDelegate, UIPageViewControllerDelegate, UIPageViewControllerDataSource, SecondViewControllerDelegate> {
    BOOL _thumbnailTapped;

}

- (void)showQuickTour:(id)sender;
- (void)Purchased;
- (IBAction) pickThumbnailImage:(id)sender;


@property (strong, nonatomic) UIPageViewController *pageViewController;
@property (strong, nonatomic) NSArray *pageTitles;
@property (strong, nonatomic) NSArray *pageImages;
@property (strong, nonatomic) NSArray *pageImages_3_5;


@property (nonatomic, weak)   IBOutlet UIBarButtonItem *editOptionsLabel;
@property (nonatomic, strong) NSCache* thumbnailCache;
@property (nonatomic, strong) NSCache* emailCountCache;
@property (nonatomic, weak)   NSIndexPath* currentIndexPath;
@property (nonatomic, readwrite) BOOL deleting;
@property (nonatomic, weak)   ABContact *returnedMailingList;
@property (nonatomic, strong) SoundEffect* deleteFX;

@end


//SecondViewController.h
@protocol SecondViewControllerDelegate <NSObject>
- (void)getBackCurrentMailingList:(id)controller didFinishEnteringItem:(ABContact *)currentMailingList;
@end


@protocol ModalViewDelegate
@optional
- (void) getBackGroup:(NSDictionary *) group;
- (void) getBackContacts:(NSArray *)c andEmails:(NSArray *)e;
- (void) getBackPastedContacts:(NSArray *)contacts;
- (void) getBackPullView:(BOOL)pullled;
@end

@interface SecondViewController : UITableViewController <ModalViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate, UIAlertViewDelegate, MFMailComposeViewControllerDelegate>
{
    ABContact *currentML;
    BOOL _isViewPulled;
}

- (IBAction) pickImage:(id)sender;
- (IBAction) composeEmail:(id)sender;
- (IBAction) PasteGroup:(id)sender;
- (IBAction) dismissPopUp:(id)sender;

@property (nonatomic, weak)     IBOutlet UIBarButtonItem *composeButton;
@property (nonatomic, strong)   NSCache*                thumbnailCache;
@property (nonatomic, strong)   ABContact*              currentML;
@property (nonatomic, strong)   NSMutableDictionary*    currentMailingList;
@property (nonatomic, strong)   NSArray*                pastedContatcs;
@property (nonatomic, strong)   NSDictionary*           groupDictionary;
@property (nonatomic, readwrite) ABRecordID             currentRecordID;
@property (nonatomic, strong)   UIView*                 fadingView;
@property (nonatomic, strong)   UILabel*                fadingLabel;
@property (nonatomic, strong)   UIActivityIndicatorView* fadingActivityIndicator;
@property (nonatomic, weak)     id <SecondViewControllerDelegate> delegate;
@property (nonatomic, strong)   SoundEffect* deleteFX;

@end


//ThirdViewController.h
@interface SettingsViewController : UIViewController <SKPaymentTransactionObserver, SKProductsRequestDelegate>
{

}

@property (strong, nonatomic) SKProductsRequest *request;
@property (strong, nonatomic) SKProduct *product;
@property (strong, nonatomic) NSString *productID;
@property (weak,   nonatomic) IBOutlet UILabel *versionLabel;
@property (weak,   nonatomic) IBOutlet UILabel *productLabel;
@property (weak,   nonatomic) IBOutlet UITextView *productDescription;
@property (weak,   nonatomic) IBOutlet UIButton *purchaseButton;
@property (weak,   nonatomic) IBOutlet UIButton *buyButton;
@property (weak,   nonatomic) IBOutlet UISwitch *soundFXSwitch;
@property (weak,   nonatomic) IBOutlet UIActivityIndicatorView *loadingIndicator;

- (IBAction)buyProduct:(id)sender;
- (IBAction)restorePurchase:(id)sender;
- (IBAction)switchSoundFX:(id)sender;
- (IBAction)showQuickTour:(id)sender;

-(void)getProductID:(UIViewController *)viewController;

@end

1 个答案:

答案 0 :(得分:1)

检查是否将secondVC指定为UINavigationControllerDelegate?如果是,请尝试在viewWillDisappear中将该值设置为nil