4

I present a modal table view within a navigation view with a Back button. The back button sends a message to the modal view's delegate to dismiss the modal view. If I scroll the table view and then tap the Back button on the navigation bar while the table view is still scrolling, the app crashes with this message:

*** -[UILayoutContainerView setUseFastMode:]: message sent to deallocated instance 0xef74650

When I PO 0xef74650 I get this:

(int) $1 = 251086416 [no Objective-C description available]

Anyone experience this before? What is the workaround or fix?

tlatkovich
  • 360
  • 6
  • 10

6 Answers6

8

I believe this is a bug in iOS 5.1 that occurs when animating the dismissing of a modal that is currently scrolling. I was getting reports from users that my app was crashing, and when I investigated I had the same error.

I created a new project with the minimal amount of code/views and was able to reproduce this crash. The only workaround I've found so far is to disable animation when dismissing a modal. I've submitted a bug report to Apple.

Chris Schwerdt
  • 1,141
  • 9
  • 9
  • I can confirm your workaround. Thanks. I don't like the way the view just disappears without an animated transition, but it beats crashing the app! Sure hope Apple fixes this one. Please update this answer in the future if you find that Apple has fixed the bug. – tlatkovich Apr 26 '12 at 13:39
  • 1
    This worked for me: NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0] ; [self.tblChildProducts scrollToRowAtIndexPath:myIP atScrollPosition:UITableViewScrollPositionTop animated:NO]; [self dismissModalViewControllerAnimated:YES]; – Slee May 24 '12 at 11:18
3

I had a similar issue, my app was crashing if the table was still scrolling and I triggered a modal view to appear over the table. The crash in my instance was thrown in cellForRowAtIndexPath, indexPath had been deallocated.

I fixed it by stopping scrolling in the viewWillDisappear method:-

- (void) viewWillDisappear:(BOOL)animated {
    [self.tableView setContentOffset:self.tableView.contentOffset animated:NO];
}

Hopefully this might help someone researching related problems!

Purpletoucan
  • 6,472
  • 2
  • 21
  • 28
1

iOS 5 has a bug in the FastModeAdditions category on UIView. This bug manifests if you have a subview of the scroll view that is being scrolled in the same run loop as the modal view controller is being dismissed.

    Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xa0000008
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x34bdef78 objc_msgSend + 16
1   UIKit                           0x35309f9e -[UIView(FastModeAdditions) _setContainerLayoutViewForFastMode:] + 98
2   UIKit                           0x351701cc -[UIView dealloc] + 568
3   UIKit                           0x3545a39e -[UIDropShadowView dealloc] + 86
4   libobjc.A.dylib                 0x34be016e _objc_rootRelease + 30
5   CoreFoundation                  0x32b882e0 CFRelease + 88

The best work around we found is to performSelector:afterDelay: the dismissal. This forces the dismissal on a later run loop and the crash no longer occurs.

This does not occur on iOS 6.

Cocoanetics
  • 8,171
  • 2
  • 30
  • 57
0

Check in setUseFastMode: to make sure you are not releasing something that you are trying to access later.

[someObject release];
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • The method setUseFastMode is part of the iOS SDK that Apple does not make available to developers. I have no idea what it is or what it does. It is essentially a black box into which I have no access. – tlatkovich Apr 16 '12 at 16:01
0

I was dismissing a modal when tapping a button inside the modal and getting this crash if its table was still scrolling. This was incorrect: after moving the dismiss code to the presenting view controller, and calling it as part of a delegate method, the crash no longer occurs.

Victor Bogdan
  • 2,022
  • 24
  • 33
0

This worked for me:

NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0]
[self.tblChildProducts scrollToRowAtIndexPath:myIP atScrollPosition:UITableViewScrollPositionTop animated:NO]
[self dismissModalViewControllerAnimated:YES]

@Slee May 24 '12 at 11:18

Community
  • 1
  • 1
kenorb
  • 155,785
  • 88
  • 678
  • 743