1

ここにある例を使用しています: http://docs.xamarin.com/guides/ios/platform_features/introduction_to_eventkit#4.3.creating-an-event-programmatically

Xamarinに問い合わせたところ、EventIdentifier代わりに使用することになっているとのことでした。CalendarItemIdentifier

カレンダー アイテムにはEventIdentifierプロパティがありません。それをキャストする方法や、そこで何をすべきかわかりません。

これが私がやっていることの基本的な例です。問題は、識別子でイベントを検索しようとすると、イベントが存在しないことCalendarItemIdentifierです。EventIdentifier

public string CreateDefaultEvent ()
        {
            // Creating an event for demonstration purposes
            // This is the sample code from your website to create an event programmatically
            EKEvent newEvent = EKEvent.FromStore ( Application.AppEventStore );
            // set the alarm for 10 minutes from now
            newEvent.AddAlarm ( EKAlarm.FromDate ( DateTime.Now.AddMinutes ( 10 ) ) );
            // make the event start 20 minutes from now and last 30 minutes
            newEvent.StartDate = DateTime.Now.AddMinutes ( 20 );
            newEvent.EndDate = DateTime.Now.AddMinutes ( 50 );
            newEvent.Title = "Get outside and do some exercise!";
            newEvent.Notes = "This is your motivational event to go and do 30 minutes of exercise. Super important. Do this.";
            newEvent.Calendar = Application.AppEventStore.DefaultCalendarForNewEvents;

            NSError e;
            Application.AppEventStore.SaveEvent ( newEvent, EKSpan.ThisEvent, out e );
            Console.WriteLine ("Event Saved, ID: " + newEvent.CalendarItemIdentifier);
            return newEvent.CalendarItemIdentifier;
        }

        public string RetrieveCreatedEvent (string _eventIdentifier)
        {
            // We will just return the event's notes to see if we got a valid event
            EKEvent savedEvent = Application.AppEventStore.EventFromIdentifier (_eventIdentifier);
            return savedEvent.Notes;
        }

前もって感謝します!

4

1 に答える 1

1

イベントを取得するときは、次のことを行う必要があります。

NSPredicate query = Util.MyEventStore.PredicateForEvents (Util.DateTimeToNSDate(startDate), Util.DateTimeToNSDate(endDate), null);
//EKCalendarItem[] eventArrary = Util.MyEventStore.EventsMatching (query);
EKEvent[] eventArrary = Util.MyEventStore.EventsMatching (query);

最初にこれを に変更した理由はわかりませんEKCalendarItem[]が、使用する必要がありますEKEvent

于 2013-03-29T04:36:34.523 に答える