Segue Failed while Dismissing Current Controller

Hi, Greetings!

I have an application in which I am performing segue while closing the current view controller. I am using like this:

DismissViewController(this);
PerformSegue("SecondViewController");

This crashes the application saying that maybe this controller was never visible. But if I comment the DismissViewController(this); , then it works fine.
Any help is appreciated. Thanks in advance.

Tagged:

Answers

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    This post likely does not have enough information for people here to look at. Please consider posting the exception/crash and more code / a small sample that shows the issue.

  • NaveedZahoorNaveedZahoor USMember
    edited February 2017

    Here is the peice of code i'm using.

    try
                    {
                        ServerIpAddress = box.StringValue;
                        IpAddressVal = combo_box.SelectedValue.ToString();
                        //this.Hide();
                        //ClientForm serverMaster = new ClientForm();
                        //serverMaster.Show();
                        DismissViewController(this);
    
                        PerformSegue("ShowClientSegue", this);
                    }
                    catch (Exception ex)
                    {
                        ModalRunner(ex.GetType().ToString(), ex.Message);
                    }
    

    Here is the details of exception:

    Exception Name: NSInternalInconsistencyException
    Description: dismissViewController:: Error: maybe this view controller was not presented?
    User Info: (null)
    
    0   CoreFoundation                      0x00007fff7b29a52b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fff8f972cad objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff7b29f232 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00007fff7ccd2390 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   AppKit                              0x00007fff79384425 -[NSViewController dismissViewController:] + 194
    5   MediClientMac                       0x0000000104f95b6c xamarin_dyn_objc_msgSendSuper + 220
    6   ???                                 0x0000000110fa428c 0x0 + 4579803788
    7   ???                                 0x000000010c71f6ba 0x0 + 4503762618
    8   MediClientMac                       0x0000000105098250 mono_jit_runtime_invoke + 2272
    9   MediClientMac                       0x0000000105148f58 do_runtime_invoke + 88
    10  MediClientMac                       0x0000000105148e66 mono_runtime_invoke + 102
    11  MediClientMac                       0x0000000104f9347d xamarin_invoke_trampoline + 5725
    12  MediClientMac                       0x0000000104f944cd xamarin_arch_trampoline + 189
    13  MediClientMac                       0x0000000104f958c1 xamarin_x86_64_common_trampoline + 110
    14  libsystem_trace.dylib               0x00007fff9048203d _os_activity_initiate + 61
    15  AppKit                              0x00007fff795ba4e7 -[NSApplication(NSResponder) sendAction:to:from:] + 456
    16  AppKit                              0x00007fff7910a245 -[NSControl sendAction:to:] + 86
    17  AppKit                              0x00007fff7910a16d __26-[NSCell _sendActionFrom:]_block_invoke + 136
    18  libsystem_trace.dylib               0x00007fff9048203d _os_activity_initiate + 61
    19  AppKit                              0x00007fff7910a0c5 -[NSCell _sendActionFrom:] + 128
    20  AppKit                              0x00007fff7914c92a -[NSButtonCell _sendActionFrom:] + 98
    21  libsystem_trace.dylib               0x00007fff9048203d _os_activity_initiate + 61
    22  AppKit                              0x00007fff79108a58 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2481
    23  AppKit                              0x00007fff7914c667 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 785
    24  AppKit                              0x00007fff791074c8 -[NSControl mouseDown:] + 832
    25  AppKit                              0x00007fff7971a73d -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 6341
    26  AppKit                              0x00007fff79716f8c -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 1942
    27  AppKit                              0x00007fff7971642a -[NSWindow(NSEventRouting) sendEvent:] + 541
    28  AppKit                              0x00007fff795b6bf5 -[NSApplication(NSEvent) sendEvent:] + 1145
    29  AppKit                              0x00007fff78e9d009 -[NSApplication run] + 1002
    30  AppKit                              0x00007fff78e67a8a NSApplicationMain + 1237
    31  ???                                 0x0000000109c4c452 0x0 + 4458857554
    32  ???                                 0x0000000109c469dd 0x0 + 4458834397
    33  MediClientMac                       0x0000000105098250 mono_jit_runtime_invoke + 2272
    34  MediClientMac                       0x0000000105148f58 do_runtime_invoke + 88
    35  MediClientMac                       0x000000010514b430 mono_runtime_exec_main + 896
    36  MediClientMac                       0x000000010514afed mono_runtime_run_main + 909
    37  MediClientMac                       0x0000000104fedbb7 mono_jit_exec + 247
    38  MediClientMac                       0x0000000104feff32 mono_main + 8098
    39  MediClientMac                       0x0000000104f961d4 xamarin_main + 980
    40  MediClientMac                       0x0000000104f96ee4 main + 36
    41  libdyld.dylib                       0x00007fff90250255 start + 1
    
  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Well cocoa is very clear that:

    Exception Name: NSInternalInconsistencyException
    Description: dismissViewController:: Error: maybe this view controller was not presented?

    is wrong. I don't know the API well enough myself, let me see if I can get someone to take a look.

  • Sure. I am waiting for your reply

Sign In or Register to comment.