gpt4 book ai didi

ios - UINavigation Controller 在显示 ViewController 时崩溃

转载 作者:行者123 更新时间:2023-11-29 02:53:16 24 4
gpt4 key购买 nike

我有一个 UINavigationController,其中有一个带有 UITableView 的 MainViewController 和一个 ToolBar 按钮。选择一个 UITableViewCell 将推送到 SecondViewController,点击工具栏按钮将推送到 ThirdViewController,两者都与 StoryBoard segue。两个 ViewController 都被第一次推送 OK,但是当 UINavigationController 首先推送 SecondViewController 并弹回 MainViewController,然后推送 ThirdViewController 将导致应用程序崩溃。所以我认为 ThirdViewController 的 代码一定有问题,但错误消息是:

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

奇怪的是,为什么在我推送 ThirdViewController 时,SecondViewController 出现在错误消息中?我放置了断点,MainViewController 上的 prepareForSegue 被调用时没有错误,ThirdViewController 上的 viewDidLoad 被调用后没有错误错误,但是当我在 viewDidLoad 结束时单击继续时,应用程序崩溃了。在启用 Zombies 的情况下使用 Instruments 显示: Instruments

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

SB截图:

所有三个 View Controller 的类定义

// 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

最佳答案

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

关于ios - UINavigation Controller 在显示 ViewController 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24229318/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com