Most of the time We are getting Crash in below code
Closed this issue · 3 comments
-
(void)removeControllerFromView:(UIViewController *)controller animated:(BOOL)animated {
if (PPSystemVersionGreaterOrEqualThan(5.0)) [controller willMoveToParentViewController:nil];
if (!PPSystemVersionGreaterOrEqualThan(5.0)) [controller viewWillDisappear:animated];
// Crash Point in this below line
[controller.view removeFromSuperview];if (!PPSystemVersionGreaterOrEqualThan(5.0)) [controller viewDidDisappear:animated];
if (PPSystemVersionGreaterOrEqualThan(5.0)) {
[controller removeFromParentViewController];
}
}
Could you please let me know why it will happen , Please help me , what may have wrong in my code.
What's the stack trace when crashing?
We have the same problem - according to Bugsense our App regularly crashes during the removeFromSuperview call. Unfortunately, I neither managed to reproduce the problem yet, nor do I a have a complete stacktrace - only the redacted stacktrace I got through Bugsense:
0 libobjc.A.dylib 0x3a1425b0 objc_msgSend + 15
1 UIKit 0x3423e1c5 <redacted> + 148
2 UIKit 0x342ec3b7 <redacted> + 146
3 UIKit 0x3430feff <redacted> + 158
4 UIKit 0x3440d29f <redacted> + 74
5 UIKit 0x34255849 <redacted> + 56
6 spin.de 0x000b6b47 -[PPRevealSideViewController removeControllerFromView:animated:] (PPRevealSideViewController.m:1024) + 174919
7 spin.de 0x000b4687 __139-[PPRevealSideViewController popViewControllerWithNewCenterController:animated:andPresentNewController:withDirection:andOffset:completion:]_block_invoke175 (PPRevealSideViewController.m:460) + 165511
8 UIKit 0x3423cab3 <redacted> + 158
9 UIKit 0x342b18ef <redacted> + 50
10 QuartzCore 0x33fe6c01 <redacted> + 208
11 libdispatch.dylib 0x3a55e4b7 <redacted> + 22
12 libdispatch.dylib 0x3a5631bd <redacted> + 224
13 CoreFoundation 0x323f2f3b <redacted> + 1290
14 CoreFoundation 0x32365ebd CFRunLoopRunSpecific + 356
15 CoreFoundation 0x32365d49 CFRunLoopRunInMode + 104
16 GraphicsServices 0x35f3e2eb GSEventRunModal + 74
17 UIKit 0x3427b301 UIApplicationMain + 1120
18 spin.de 0x0008e087 main (main.m:14) + 8327
Ok, I found the cause, at least for our crash. It's not so much related to PPRevealSideViewController as to UITableView, but I post it here in case others have the same problem: We had an input field in the side menu. The crashes are caused by giving the input field focus, then scrolling it out of view, then closing the side menu. The removeFromSuperview call will try to resignFirstResponder for the input field, which was in a recycled table view cell. The solution is pretty simply: prevent scrolling while focus is on the input field, then you won't have the delayed crash during closing the menu.