Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Bug: DisplayAlert in iOS can throw exception

$
0
0

When running this statement in Android it works fine and display alert only shows one button:

this.DisplayAlert("Facebook", "Facebook button", "OK", string.Empty);

When running the same line in iOS I get the following error:

{MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
  at MonoTouch.UIKit.UIAlertView.Show () [0x00010] in /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIAlertView.g.cs:226 
  at Xamarin.Forms.Platform.iOS.Platform.<.ctor>b__1 (Xamarin.Forms.Page sender, Xamarin.Forms.AlertArguments arguments) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.MessagingCenter+<>c__DisplayClass1`2[Xamarin.Forms.Page,Xamarin.Forms.AlertArguments].<Subscribe>b__0 (System.Object sender, System.Object args) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.MessagingCenter.InnerSend (System.String message, System.Type senderType, System.Type argType, System.Object sender, System.Object args) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.MessagingCenter.Send[Page,AlertArguments] (Xamarin.Forms.Page sender, System.String message, Xamarin.Forms.AlertArguments args) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Page.DisplayAlert (System.String title, System.String message, System.String accept, System.String cancel) [0x00000] in <filename unknown>:0 
  at LoginTest.Forms.Login.Facebook_Clicked (System.Object sender, System.EventArgs e) [0x00002] in c:\Users\kevinf\Documents\Visual Studio 2013\Projects\LoginTest\LoginTest\LoginTest\Forms\Login.xaml.cs:36 
NSInvalidArgumentException: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
    0   CoreFoundation                      0x016391e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x050178e5 objc_exception_throw + 44
    2   CoreFoundation                      0x015ebabc -[__NSArrayM insertObject:atIndex:] + 844
    3   CoreFoundation                      0x015eb760 -[__NSArrayM addObject:] + 64
    4   UIKit                               0x02f01b68 -[UIAlertView _modalItemForNeueCompatibility] + 347
    5   UIKit                               0x02f02c45 -[UIAlertView popupAlertAnimated:animationType:atOffset:] + 53
    6   UIKit                               0x02f03327 -[UIAlertView popupAlertAnimated:animationType:] + 56
    7   UIKit                               0x02f0835c -[UIAlertView showWithAnimationType:] + 48
    8   UIKit                               0x02f0838a -[UIAlertView show] + 41
    9   ???                                 0x154652b8 0x0 + 356930232
    10  ???                                 0x154980f4 0x0 + 357138676
    11  ???                                 0x15496c04 0x0 + 357133316
    12  ???                                 0x154969f4 0x0 + 357132788
    13  ???                                 0x154962b0 0x0 + 357130928
    14  ???                                 0x0e5b3fec 0x0 + 240861164
    15  ???                                 0x1548e3fc 0x0 + 357098492
    16  ???                                 0x1548e2f4 0x0 + 357098228
    17  ???                                 0x1548e16e 0x0 + 357097838
    18  ???                                 0x1548e074 0x0 + 357097588
    19  ???                                 0x1548dfaf 0x0 + 357097391
    20  ???                                 0x1315ed35 0x0 + 320204085
    21  LoginTest                           0x000f595b mono_jit_runtime_invoke + 843
    22  LoginTest                           0x00193f5f mono_runtime_invoke + 127
    23  LoginTest                           0x00243c2f monotouch_trampoline + 4991
    24  libobjc.A.dylib                     0x05029880 -[NSObject performSelector:withObject:withObject:] + 77
    25  UIKit                               0x029f53b9 -[UIApplication sendAction:to:from:forEvent:] + 108
    26  UIKit                               0x029f5345 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    27  UIKit                               0x02af6bd1 -[UIControl sendAction:to:forEvent:] + 66
    28  UIKit                               0x02af6fc6 -[UIControl _sendActionsForEvents:withEvent:] + 577
    29  UIKit                               0x02af6243 -[UIControl touchesEnded:withEvent:] + 641
    30  UIKit                               0x02a34ddd -[UIWindow _sendTouchesForEvent:] + 852
    31  UIKit                               0x02a359d1 -[UIWindow sendEvent:] + 1117
    32  UIKit                               0x02a075f2 -[UIApplication sendEvent:] + 242
    33  UIKit                               0x029f1353 _UIApplicationHandleEventQueue + 11455
    34  CoreFoundation                      0x015c277f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    35  CoreFoundation                      0x015c210b __CFRunLoopDoSources0 + 235
    36  CoreFoundation                      0x015df1ae __CFRunLoopRun + 910
    37  CoreFoundation                      0x015de9d3 CFRunLoopRunSpecific + 467
    38  CoreFoundation                      0x015de7eb CFRunLoopRunInMode + 123
    39  GraphicsServices                    0x062635ee GSEventRunModal + 192
    40  GraphicsServices                    0x0626342b GSEventRun + 104
    41  UIKit                               0x029f3f9b UIApplicationMain + 1225
    42  ???                                 0x13779838 0x0 + 326604856
    43  ???                                 0x13777754 0x0 + 326596436
    44  ???                                 0x13777328 0x0 + 326595368
    45  ???                                 0x1377746f 0x0 + 326595695
    46  LoginTest                           0x000f595b mono_jit_runtime_invoke + 843
    47  LoginTest                           0x00193f5f mono_runtime_invoke + 127
    48  LoginTest                           0x00199a71 mono_runtime_exec_main + 401
    49  LoginTest                           0x00199834 mono_runtime_run_main + 628
    50  LoginTest                           0x000543fd mono_jit_exec + 93
    51  LoginTest                           0x00234e70 main + 2784
    52  LoginTest                           0x00002e15 start + 53
}
    base: {System.Exception}
    Message: "Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: *** -[__NSArrayM insertObjec…"
    Name: "NSInvalidArgumentException"
    NSException: {MonoTouch.Foundation.NSException}
    Reason: "*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil"

Putting a "" in the second button parameter similarly errors out. If I put in something like this it works fine:

this.DisplayAlert("Facebook", "Facebook button", "OK", "BugButton");

On Windows Phone it shows the second button with no label but does not throw an exception. I expect these should probably exhibit the same behavior.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>