قالب وردپرس درنا توس
Home / IOS Development / ios – NavigationController is NULL in custom segue in random sessions

ios – NavigationController is NULL in custom segue in random sessions



I'm trying to fix a crash I can't reproduce in QA, but seems to happen to many users (on different devices and iOS versions).

Crash message received from users: [19659003] SIGABRT: Object reference not set to an instance of an object

revealFromBottom.Perform ()
(wrapper managed to native) ObjCRuntime.Messaging.objc_msgSendSuper (intptr, intptr, intptr, intptr)
UIViewController.PerformSegue (System.String identifies, Foundation.NSObject sends)
GamePlayViewController + d__44.MoveNext ()
AsyncMethodBuilderCore + <> c.b__6_0 (System.Object state)
NSAsyncSynchronizationContextDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int, string [] intptr, intptr)
UIApplication.Main (System.String [] args, System.IntPtr principal, System.IntPtr delegated)
UIApplication.Main (System.String [] args, System.String principalClassName, System.String delegateClassName)
Application.Main (System.String [] args)

revealFromBottom is a custom story:

  public subclass revealFromBottom: UIStoryboardSegue
{
CAT transition transition;

public revealFromBottom (IntPtr handle): base (handle)
{
}

Public override invalid Perform ()
{
CATransaction.Begin ();

CATransaction.CompletionBlock = () =>
{
};


transition = new CAT transition ();
transition.Duration = 0.6;
transition.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseOut);
transition.Type = CAAnimation.TransitionPush;
transition.Subtype = CAAnimation.TransitionFromTop;
SourceViewController.NavigationController.View.Layer.AddAnimation (transition, CALayer.Transition);
SourceViewController.NavigationController.PushViewController (DestinationViewController, false);
CATransaction.Commit ();

}
}

After examining this crash and collecting some more data and logs, the app seems to crash because the NavigationController for SourceViewController is NULL:

  SourceViewController.NavigationController.View.Layer.AddAnimation (transition, CALayer.Transition) ;

Given that crash is not consistent and + 95% of sessions do not crash ̵

1; what can cause NavigationController to be NULL in some sessions?


Source link