IOS - crash when loadViewIfRequired

I usually don’t want to ask SO to understand my crash report, but (a) I can learn a lot about reading crash reports from experts here, and (b) I understand that I don’t know, I understand how much about the navigation flow as I hoped (this part is specific to the crash report I think).

So, I hope someone runs into one problem and can help me understand why my application crashes.

He only sometimes falls, which marries me, why he is intermittent. However, when it crashes, it crashes in the same place with the same stack trace (shown below).

Now I see that it crashes in cmdPressed (there is a lot of code in this method), but it's hard for me to understand something deeper.

From the crash report read below, does anyone have any tips on why my application crashes ??? And why can this be inconsistent?

 Thread 0 Crashed: 0 libobjc.A.dylib 0x344dd5aa _objc_msgSend + 10 1 UIKit 0x3374458d -[UIViewController loadViewIfRequired] + 365 2 UIKit 0x33799133 -[UIViewController contentScrollView] + 27 3 UIKit 0x33799079 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 29 4 UIKit 0x33798f5d -[UINavigationController _layoutViewController:] + 33 5 UIKit 0x33798e81 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 273 6 UIKit 0x337985c1 -[UINavigationController _startTransition:fromViewController:toViewController:] + 65 7 UIKit 0x337984a9 -[UINavigationController _startDeferredTransitionIfNeeded:] + 325 8 UIKit 0x337e54b1 -[UINavigationController defaultFirstResponder] + 129 9 UIKit 0x33797849 -[UIResponder(Internal) _deepestDefaultFirstResponder] + 25 10 UIKit 0x337976fb -[UIResponder(Internal) _promoteDeepestDefaultFirstResponder] + 31 11 UIKit 0x33813349 -[UIWindowController transitionViewDidStart:] + 81 12 UIKit 0x337bf8db -[UITransitionView transition:fromView:toView:removeFromView:] + 991 13 UIKit 0x33a00059 __91-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]_block_invoke_0236 + 389 14 UIKit 0x33812961 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 4761 15 UIKit 0x33810fc7 -[UIViewController presentViewController:withTransition:completion:] + 3395 16 UIKit 0x33933257 -[UIViewController presentModalViewController:animated:] + 31 17 MyApp 0x00044973 -[AppViewController cmdPressed] (AppViewController.mm:553) 18 UIKit 0x338100a5 -[UIApplication sendAction:to:from:forEvent:] + 73 19 UIKit 0x33810057 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 31 20 UIKit 0x33810035 -[UIControl sendAction:to:forEvent:] + 45 21 UIKit 0x3380f8eb -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 503 22 UIKit 0x3380fde1 -[UIControl touchesEnded:withEvent:] + 489 23 UIKit 0x337385f1 -[UIWindow _sendTouchesForEvent:] + 525 24 UIKit 0x33725801 -[UIApplication sendEvent:] + 381 25 UIKit 0x3372511b _UIApplicationHandleEvent + 6155 26 GraphicsServices 0x389085a3 _PurpleEventCallback + 591 27 GraphicsServices 0x389081d3 PurpleEventCallback + 35 28 CoreFoundation 0x3a5c8173 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 35 29 CoreFoundation 0x3a5c8117 __CFRunLoopDoSource1 + 139 30 CoreFoundation 0x3a5c6f99 __CFRunLoopRun + 1385 31 CoreFoundation 0x3a539ebd _CFRunLoopRunSpecific + 357 32 CoreFoundation 0x3a539d49 _CFRunLoopRunInMode + 105 33 GraphicsServices 0x389072eb _GSEventRunModal + 75 34 UIKit 0x337792f9 _UIApplicationMain + 1121 35 MyApp 0x0003d083 main (main.m:44) 

Any advice is appreciated. Thanks!!!

+6
source share
3 answers

I know this is late and I'm not sure if this will solve your problem or not. But when I ran into this problem (related to loadViewIfRequired) and struggled a lot, because in my case it sometimes crashed. I called [UITableViewController tableView] from outside the tableview controller class that was called before loading the tableview. Since my tableView was not loaded properly, so my UITableViewController class tried to call the loadViewIfRequired API and which was calling ViewDidLoad in another thread (not in the main thread). I fixed this without calling [UITableViewController tableView] before my tableviewcontroller loader loaded, and I loaded it into the main thread, which fixed my problem.

0
source

I ran into the same problem. For me, the problem was that I changed the xib file, but forgot to connect all the previous outputs.

0
source

Try adding this method. Hope this helps you.

 -(void)setView:(UIView*)view { if(view != nil ) [super setView:view]; else NSLog(@"Memory"); } 
-3
source

Source: https://habr.com/ru/post/944064/


All Articles