iOS Calendar [Xamarin]


#1

Tested the new calendar in Xamarin and got a crash when trying to catch the events that are generated when the user taps an event.

I cretaed a new class in the birthday sample application called SBDelegate:

public class SBDelegate : SCalendarDelegate
    {
        public SBDelegate ()
        {
        }

        public override void ShinobiCalendarSelectedEvent (ShinobiCalendar calendar, SCalendarEvent e) {
            e.ToString ();
        }
    }  

In the "main" function I added it as the delegate class to catch events.

SBDelegate tappedEvent = new SBDelegate ();
BirthdayCalendar.Delegate = tappedEvent;  

Got the following error when trying to tap an event:

2015-04-09 11:58:23.488 Birthday[12188:3570116] critical: Stacktrace:

2015-04-09 11:58:23.489 Birthday[12188:3570116] critical:   at <unknown> <0xffffffff>

2015-04-09 11:58:23.490 Birthday[12188:3570116] critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff>

2015-04-09 11:58:23.491 Birthday[12188:3570116] critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62

2015-04-09 11:58:23.492 Birthday[12188:3570116] critical:   at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:45

2015-04-09 11:58:23.493 Birthday[12188:3570116] critical:   at Birthday.Application.Main (string[]) [0x00008] in /Users/tereng/Projects/shinobicalendars/Xamarin/samples/Birthday/Birthday/Main.cs:22

2015-04-09 11:58:23.494 Birthday[12188:3570116] critical:   at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>

2015-04-09 11:58:23.495 Birthday[12188:3570116] critical: 

Native stacktrace:

2015-04-09 11:58:23.549 Birthday[12188:3570116] critical: 0   Birthday                            0x0000000100229804 mono_handle_native_sigsegv + 268

2015-04-09 11:58:23.550 Birthday[12188:3570116] critical: 1   Birthday                            0x000000010023365c mono_sigsegv_signal_handler + 316

2015-04-09 11:58:23.551 Birthday[12188:3570116] critical: 2   libsystem_platform.dylib            0x000000019777c95c _sigtramp + 68

2015-04-09 11:58:23.552 Birthday[12188:3570116] critical: 3   libobjc.A.dylib                     0x0000000196f59eac <redacted> + 164

2015-04-09 11:58:23.552 Birthday[12188:3570116] critical: 4   libobjc.A.dylib                     0x0000000196f59eac <redacted> + 164

2015-04-09 11:58:23.554 Birthday[12188:3570116] critical: 5   libobjc.A.dylib                     0x0000000196f4e938 object_getInstanceVariable + 76

2015-04-09 11:58:23.554 Birthday[12188:3570116] critical: 6   Birthday                            0x00000001002e7be0 get_raw_gchandle + 40

2015-04-09 11:58:23.556 Birthday[12188:3570116] critical: 7   Birthday                            0x00000001002e7b6c get_gchandle + 24

2015-04-09 11:58:23.556 Birthday[12188:3570116] critical: 8   Birthday                            0x00000001002e7764 xamarin_get_gchandle + 24

2015-04-09 11:58:23.557 Birthday[12188:3570116] critical: 9   Birthday                            0x00000001002e76a4 xamarin_get_nsobject_with_type_for_ptr_created + 124

2015-04-09 11:58:23.558 Birthday[12188:3570116] critical: 10  Birthday                            0x00000001002f08fc xamarin_trampoline + 3728

2015-04-09 11:58:23.559 Birthday[12188:3570116] critical: 11  Birthday                            0x00000001001f36b4 -[SCalendarDatasourceDelegateProxy shinobiCalendar:selectedEvent:] + 180

2015-04-09 11:58:23.559 Birthday[12188:3570116] critical: 12  Birthday                            0x00000001001e78f4 __36-[SCalendarWeekView weekViewTapped:]_block_invoke + 236

2015-04-09 11:58:23.560 Birthday[12188:3570116] critical: 13  Birthday                            0x00000001001e7dac -[SCalendarWeekView findEventAndDateFromTapGestureRecognizer:withCompletion:] + 816

2015-04-09 11:58:23.561 Birthday[12188:3570116] critical: 14  Birthday                            0x00000001001e77e8 -[SCalendarWeekView weekViewTapped:] + 112

2015-04-09 11:58:23.562 Birthday[12188:3570116] critical: 15  UIKit                               0x000000018a96b648 <redacted> + 276

2015-04-09 11:58:23.562 Birthday[12188:3570116] critical: 16  UIKit                               0x000000018a803d30 <redacted> + 580

2015-04-09 11:58:23.563 Birthday[12188:3570116] critical: 17  UIKit                               0x000000018ac71574 <redacted> + 60

2015-04-09 11:58:23.563 Birthday[12188:3570116] critical: 18  UIKit                               0x000000018a7c838c <redacted> + 292

2015-04-09 11:58:23.564 Birthday[12188:3570116] critical: 19  UIKit                               0x000000018a7c6738 <redacted> + 2504

2015-04-09 11:58:23.565 Birthday[12188:3570116] critical: 20  CoreFoundation                      0x0000000185f7ed98 <redacted> + 32

2015-04-09 11:58:23.566 Birthday[12188:3570116] critical: 21  CoreFoundation                      0x0000000185f7bd24 <redacted> + 360

2015-04-09 11:58:23.566 Birthday[12188:3570116] critical: 22  CoreFoundation                      0x0000000185f7c104 <redacted> + 836

2015-04-09 11:58:23.567 Birthday[12188:3570116] critical: 23  CoreFoundation                      0x0000000185ea91f4 CFRunLoopRunSpecific + 396

2015-04-09 11:58:23.568 Birthday[12188:3570116] critical: 24  GraphicsServices                    0x000000018f2d36fc GSEventRunModal + 168

2015-04-09 11:58:23.569 Birthday[12188:3570116] critical: 25  UIKit                               0x000000018a83a10c UIApplicationMain + 1488

2015-04-09 11:58:23.569 Birthday[12188:3570116] critical: 26  Birthday                            0x0000000100074288 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 344

2015-04-09 11:58:23.570 Birthday[12188:3570116] critical: 27  Birthday                            0x0000000100051e10 UIKit_UIApplication_Main_string___intptr_intptr + 48

2015-04-09 11:58:23.570 Birthday[12188:3570116] critical: 28  Birthday                            0x0000000100051dcc UIKit_UIApplication_Main_string___string_string + 188

2015-04-09 11:58:23.571 Birthday[12188:3570116] critical: 29  Birthday                            0x0000000100030114 Birthday_Application_Main_string__ + 164

2015-04-09 11:58:23.572 Birthday[12188:3570116] critical: 30  Birthday                            0x000000010014c220 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 160

2015-04-09 11:58:23.573 Birthday[12188:3570116] critical: 31  Birthday                            0x0000000100235764 mono_jit_runtime_invoke + 1264

2015-04-09 11:58:23.574 Birthday[12188:3570116] critical: 32  Birthday                            0x0000000100281700 mono_runtime_invoke + 128

2015-04-09 11:58:23.574 Birthday[12188:3570116] critical: 33  Birthday                            0x0000000100285874 mono_runtime_exec_main + 404

2015-04-09 11:58:23.575 Birthday[12188:3570116] critical: 34  Birthday                            0x00000001002e6518 xamarin_main + 2120

2015-04-09 11:58:23.576 Birthday[12188:3570116] critical: 35  Birthday                            0x00000001001d2e14 main + 112

2015-04-09 11:58:23.577 Birthday[12188:3570116] critical: 36  libdyld.dylib                       0x00000001975cea08 <redacted> + 4

2015-04-09 11:58:23.578 Birthday[12188:3570116] critical: 

I am probably using it wrong but if you can help me it would be appriciated.

Also one important feedback regarding the calendar that looks nice and all but it is not possible to change the starting and ending hours in the day view or am I missing something here. If I know that my events will always be between 10:00 and 18:00 it will look compressed and not very user friendly. 


#2

Hi Terje,

I’m afraid I can’t reproduce your crash.

I created an SBirthdayDelegate class as follows:

using System;
using Shinobi.Calendars;

namespace Birthday
{
	public class SBirthdayDelegate : SCalendarDelegate
	{
		public SBirthdayDelegate ()
		{
		}

		public override void ShinobiCalendarSelectedEvent (ShinobiCalendar calendar, SCalendarEvent e)
		{
			Console.WriteLine ("Selected an event");
			Console.WriteLine(e.Name);
		}
	}
}

And then within SBirthdayViewController.cs

public override void ViewDidLoad() {
	// Existing code ...

        // New code
	BirthdayCalendar.Delegate = new SBirthdayDelegate ();

	// Existing code ...
}

I could see the name of the event being written to the console.

Could you give it another go and see if you’re still seeing this issue?

Regarding your feature request - thanks for that, we’ll certainly take it on board and think about adding it to a future version!

Kind regards,

Sam


#3

I got it to work now after updating to the latest versions of Xamarin/Xamarin.Forms.

Thanks for your reply.