I have a UITableView. In the first section of this I have a custom
UITableViewCell. This cell is loaded from EditorTableCell.xib which was
created as a View & View Controller in monodevelop, then the view removed in
Interface Editor and replaced with a UITableViewCell. The view outlet is
set. I have added 3 items: a text field, and two UIButtons. When I press one
of the buttons, it executes the below code:

partial void onBtnImageTouchUpInside (NSObject sender)
                {

                        var actionSheet = new UIActionSheet("") { "Take Photo", 
"Choose Photo",
"Cancel"} ;
                        actionSheet.Style = UIActionSheetStyle.BlackTranslucent;
                        actionSheet.CancelButtonIndex = 2;
                        
actionSheet.ShowInView(ContainingViewControllerReference.View);
                         
                        picker = new UIImagePickerController();
                        picker.Delegate = new PickerDelegate(this);
                        
                
if(UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front)
||
                          
UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Rear))
                        {  //At least one camera device is available:
                                actionSheet.Clicked += delegate(object sender2, 
UIButtonEventArgs e2) {
                                        switch(e2.ButtonIndex)
                                        {
                                        case 0: //Take photo with camera:
                                                picker.SourceType = 
UIImagePickerControllerSourceType.Camera;
                                                
                                                //Switch to front camera if one 
is available:
                                        
if(UIImagePickerController.IsCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front))
                                                        picker.CameraDevice = 
UIImagePickerControllerCameraDevice.Front;
                                                else
                                                        picker.CameraDevice = 
UIImagePickerControllerCameraDevice.Rear;
                                                picker.CameraCaptureMode =
UIImagePickerControllerCameraCaptureMode.Photo;
                                                picker.AllowsEditing = true;
                                        
ContainingViewControllerReference.PresentModalViewController(picker,true);
                                                
                                                break;
                                                
                                                
                                        case 1: //Choose from photo library:
                                                picker.SourceType = 
UIImagePickerControllerSourceType.PhotoLibrary;
                                                picker.AllowsEditing = true;
                                                //picker.CameraCaptureMode =
UIImagePickerControllerCameraCaptureMode.Photo;
                                                //string[] available =
UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                                        
ContainingViewControllerReference.PresentModalViewController(picker,true);
                                                
                                                break;
                                                
                                        case 2:
                                                //Cancelled
                                                break;
                                        }
                                        
                                        
                                } ;
                        }
                        else //No camera device available (Touch, iPad 1 etc...)
                        {
                                picker.SourceType = 
UIImagePickerControllerSourceType.PhotoLibrary;
                                picker.AllowsEditing = true;
                        
ContainingViewControllerReference.PresentModalViewController(picker,true);
                                
         
                        }
                }

Now, this ONLY works if I put a breakpoint around the start of the above
method. If it runs through without a breakpoint, I hit the below error:

  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) <0x0010f>
  at MonoTouch.UIKit.UIApplication.Main (string[]) <0x00023>
  at ApolloApp.Application.Main (string[]) [0x00000] in
/Users/Dermot/Projects/Apollo/Apollo/Main.cs:15
  at (wrapper runtime-invoke) object.runtime_invoke_dynamic
(intptr,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

        0   Apollo                              0x00688e18
mono_handle_native_sigsegv + 456
        1   Apollo                              0x0066e7e4
mono_sigsegv_signal_handler + 428
        2   libsystem_c.dylib                   0x32c00539 _sigtramp + 48
        3   UIKit                               0x371d59eb -[UIApplication
sendAction:to:from:forEvent:] + 62
        4   UIKit                               0x371d59a7 -[UIApplication
sendAction:toTarget:fromSender:forEvent:] + 30
        5   UIKit                               0x371d5985 -[UIControl
sendAction:to:forEvent:] + 44
        6   UIKit                               0x371d56f5 -[UIControl(Internal)
_sendActionsForEvents:withEvent:] + 492
        7   UIKit                               0x371d602d -[UIControl
touchesEnded:withEvent:] + 476
        8   UIKit                               0x371d450f -[UIWindow
_sendTouchesForEvent:] + 318
        9   UIKit                               0x371d3f01 -[UIWindow 
sendEvent:] +
380
        10  UIKit                               0x371ba4ed -[UIApplication
sendEvent:] + 356
        11  UIKit                               0x371b9d2d
_UIApplicationHandleEvent + 5808
        12  GraphicsServices                    0x305ecdf3 PurpleEventCallback +
882
        13  CoreFoundation                      0x33de5553
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
        14  CoreFoundation                      0x33de54f5 __CFRunLoopDoSource1 
+
140
        15  CoreFoundation                      0x33de4343 __CFRunLoopRun + 1370
        16  CoreFoundation                      0x33d674dd CFRunLoopRunSpecific 
+
300
        17  CoreFoundation                      0x33d673a5 CFRunLoopRunInMode + 
104
        18  GraphicsServices                    0x305ebfcd GSEventRunModal + 156
        19  UIKit                               0x371e8743 UIApplicationMain + 
1090
        20  Apollo                              0x00233764
wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr
+ 240
        21  Apollo                              0x00205ca8
MonoTouch_UIKit_UIApplication_Main_string__ + 36
        22  Apollo                              0x000e0648
ApolloApp_Application_Main_string__ + 128
        23  Apollo                              0x0044fe64
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200
        24  Apollo                              0x0066e408 
mono_jit_runtime_invoke
+ 2892
        25  Apollo                              0x00766714 mono_runtime_invoke +
200
        26  Apollo                              0x0076983c 
mono_runtime_exec_main +
836
        27  Apollo                              0x0076883c 
mono_runtime_run_main +
968
        28  Apollo                              0x006754b8 mono_jit_exec + 244
        29  Apollo                              0x00668820 main + 3928
        30  Apollo                              0x00002988 start + 40

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


Any ideas?!

--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/SIGSEGV-Error-when-tapping-a-button-tp4213187p4213187.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to