简体   繁体   中英

Crash after dismissing an UIViewController

Since a short while I have a problem with my App that as soon as I dismiss a specific UIViewController the App crashes with Tread 1:breakpoint 1.1 7.1.

I have narrowed the problem down to a 'Container view' which is placed in the view that is dismissed. I noticed that the main controller is dealloced first, and the the container view controller, but don't see what the problem is. I am not sure when this problem was introduced as I was working a few days on particular interface issues and never used the 'navigate back' option.

I know the above description is very vague, but any suggestions how to debug the possible cause would be very very welcome as I have spend hours at it at this stage.

#0  0x00000001954440a8 in objc_exception_throw ()
#1  0x0000000184d05d88 in +[NSException raise:format:] ()
#2  0x0000000185b59f00 in NSKVODeallocate ()
#3  0x0000000184be5378 in CFRelease ()
#4  0x0000000184bf1938 in -[__NSArrayM dealloc] ()
#5  0x000000019545d724 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#6  0x0000000184be8f94 in _CFAutoreleasePoolPop ()
#7  0x0000000184cbb750 in __CFRunLoopRun ()
#8  0x0000000184be91f4 in CFRunLoopRunSpecific ()
#9  0x000000018dd775a4 in GSEventRunModal ()
#10 0x000000018951a784 in UIApplicationMain ()
#11 0x00000001000cdc04 in main at /Users/Luuk/Documents/Xcode development/idoms-portal/iDoms/main.m:14
#12 0x0000000195ab2a08 in start ()

EDIT: I have narrowed it down to linking the container to the view controller:

@interface DOPrototypeViewController : UIViewController <DOContentSizeCallback> {

    @protected
    DOMediaPlayerHelper* _mediaPlayerHelper;
    __weak NSString* _viewTitle;

    IBOutlet UIBarButtonItem *_previousPageBttn;
    IBOutlet UIBarButtonItem *_nextPageBttn;

    __weak IBOutlet UIView* _contentContainer;
    __weak IBOutlet UIScrollView* _scrollView;
}

@property (nonatomic, weak)  NSString* viewTitle;;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentViewHeightConstraint;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentViewWidthConstraint;

Once the container in IB is linked the problem occurs. As mentioned above, it seems that the DOPrototypeViewController is unloaded first, before the contentContainer controller. It must have something to do with a link back to the parent view of the contentContainer I would feel.

I've had these sort of crashes before. Normally a message is sent to an object that A: No longer exists. B: Doesn't recognise the selector.

Start off at looking through the stack trace. See what the last couple of calls were right before the crash. This normally points you in the right direction.

Also, post the crash log and stack trace here if you get stuck.

It was a reference. I added an observer [[self view] addObserver:self forKeyPath:@"frame" options:0 context:nil]; in two controllers, and while I fixed one, never saw the second and did not remove it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM