标签: ekevent

如何在 iOS 中更新或编辑 EKEvent 并使用标识符存储在本机日历中?

我在我的应用程序中使用 EKEvent 来获取所有商店事件,我想通过标识符编辑任何特定事件并重新保存在现有的..那么我应该怎么做?

EKEventStore *store = [EKEventStore new];
    EKEvent *event = [EKEvent eventWithEventStore:store];

    event.title = @"abc";
    event.notes= @"this is updated notes";

    event.calendar = [store defaultCalendarForNewEvents];
    NSError *err = nil;

    [store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];
Run Code Online (Sandbox Code Playgroud)

这段代码用于我用来存储事件,但是在哪里传递标识符以仅更新特定事件?

iphone ios ekevent ekeventkit ekeventstore

6
推荐指数
1
解决办法
4771
查看次数

用EKEvent在iphone中播放闹钟

我正在使用EKEvent类来存储事件的应用程序,我希望我的应用程序在该事件发生时触发警报.我不知道如何在iPhone中播放闹钟.

alarm ios ekevent

5
推荐指数
1
解决办法
4679
查看次数

如何在将来的日期中获取特定的周期性EKEvent?

我将重复事件(EKEvent)写入了Calendar。如何在特定日期获取和修改这些重复事件之一?

这些事件是通过以下代码创建的:

+ (void) writeTestEvent{

    EKEventStore *eventStore = [[EKEventStore alloc] init];
    EKEvent *event = [EKEvent eventWithEventStore:eventStore];

    event.calendar = [eventStore defaultCalendarForNewEvents];
    event.title = @"Hello World!";
    event.startDate = [NSDate date];
    event.endDate = [NSDate date];

    EKRecurrenceRule *recurrenceRule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:EKRecurrenceFrequencyDaily interval:1 end:nil];
    [event addRecurrenceRule:recurrenceRule];

    [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
        if (granted) {
            BOOL isSaved = [eventStore saveEvent:event span:EKSpanFutureEvents commit:YES error:&error];
            NSLog(@"isSaved: (%d) with error: %@", isSaved, error);
        } else {
            NSLog(@"not granted with error: %@", error);
        }
    }];
}
Run Code Online (Sandbox Code Playgroud)

-predicateForEventsWithStartDate:endDate:calendars: …

ekevent ekeventkit ekeventstore

5
推荐指数
1
解决办法
1702
查看次数

saveEvent返回“未设置日历”

我正在尝试从我的应用程序将事件保存到日历中。我的代码适用于iOS 7,但在iOS 6上,它返回未设置日历。

在iOS 7上,该应用程序会提示用户授予对日历的访问权限,但对于iOS 6则不会出现这样的提示。尽管在设置->隐私->日历中已向该应用程序授予访问权限

是的,我已经实现了requestAccessToEntityType:completion:

这是我的代码段

EKEventStore *objStore = [[EKEventStore alloc]init];

if ([objStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
{
    // iOS 6 and later
    [objStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            if (granted)
        {
            // code here for when the user allows your app to access the calendar
            EKEvent *calEvent = [EKEvent eventWithEventStore:objStore];
            calEvent.title = mstrTitleEvent;
            calEvent.startDate = self.dateToBeSet;
            calEvent.endDate = self.dateToBeSet;
            calEvent.calendar = objStore.defaultCalendarForNewEvents;

            EKAlarm *objAlarm = [EKAlarm alarmWithAbsoluteDate:self.dateToBeSet];
            [calEvent …
Run Code Online (Sandbox Code Playgroud)

ios ekevent ekeventkit ekeventstore

5
推荐指数
1
解决办法
2811
查看次数

当我添加超过1000的多个本地通知时,iPhone重新启动

在我的基于日历的应用程序中,我还从我的应用程序创建了所有事件的本地通知.

在每次发布时,我删除所有通知并创建2年.所以,它的1000以上事件就在那里.

当本地通知创建设备内存高达80 MB时.但没有创建我的应用程序只使用75而且能源使用非常高的 设备产生热量并且每次都自动重启,所以即使我也无法获得崩溃日志.

我收到日志:

XPC连接中断[Common]终止,因为没有系统应用程序.

注意:我的应用程序最低IOS是:iOS 9.仅在nsoperation上创建通知.高级谢谢你的帮助.

    -(void)addLocalNotifiction:(EKEvent*)event andType:(NSString *)eventType andBody:(NSString*)body  {

       @autoreleasepool {
        UILocalNotification *localNotification = [[UILocalNotification alloc] init];

        NSDictionary *infoDict = @{@"identifier"            :   event.eventIdentifier ?: @"",
                                   @"calendarIdentifier"    :   event.calendar.calendarIdentifier ?: @"",
                                   @"date"                  :   event.startDate ?: @"",
                                   @"type"                  :   eventType,
                                   @"mode"                  :   @"new"};
        localNotification.alertBody = body;
        localNotification.userInfo = infoDict;
        localNotification.fireDate = event.alarms[0].absoluteDate;
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
      }
}
Run Code Online (Sandbox Code Playgroud)

我将在循环上调用上面的函数.

objective-c nscalendar ios uilocalnotification ekevent

5
推荐指数
0
解决办法
119
查看次数

EKEventEditViewController的“添加”和“取消”按钮没有响应

我正在尝试使用添加日历事件EKEventEditViewController。我已经安装一EKEventEditViewController正确与EKEventStoreEKEvent,和其editViewDelegate作为呈现视图控制器。该EKEventEditViewController礼物本身正确的,但是当我按下任一“添加”或“取消”,didCompleteWithAction不叫EKEventEditViewDelegate。但是,我确实收到此错误(虽然没有崩溃):

[EKCalendarItemLocationInlineEditItem isSubitemAtIndexSaveable:] - Location Inline Edit Item didn't have a text label on its non conference location cell; will return NO
Run Code Online (Sandbox Code Playgroud)

你可以看到这里EKCalendarItemLocationInlineEditItemEventKitUI框架。

似乎这与位置有关,但我似乎无法弄清楚。有没有人遇到此错误,或者有任何进一步调试的提示?谢谢!我正在运行iOS 11和Xcode 9.0.1。

calendar objective-c eventkit ekevent ekeventkit

5
推荐指数
1
解决办法
756
查看次数

响应EKEventEditViewController中的"取消"或"完成"

我正在使用EKEventEditViewController,我可以填充我需要的信息.我被授予访问日历和所有内容的权限.我的问题是当我点击"取消"没有任何反应.当我点击"完成"时,我收到错误消息,表示没有设置日历,没有设置日期,"事件不属于该事件存储".

我不认为我的didCompleteWithAction委托方法被调用.

我的viewController符合:

@interface EventoViewController : UIViewController <EKEventEditViewDelegate>
Run Code Online (Sandbox Code Playgroud)

当我尝试将self设置为delegate时,我收到错误:

sending EventoViewController *const__strong' to parameter of incompatible type 'id<UINavigationControllerDelegate>'
Run Code Online (Sandbox Code Playgroud)

原始代码.h

#import <UIKit/UIKit.h>
#import <EventKit/EventKit.h>
#import <EventKitUI/EventKitUI.h>

@interface EventoViewController : UIViewController <EKEventEditViewDelegate>

@property (weak, nonatomic) IBOutlet UILabel *eventDetailTitleLabel;
@property (weak, nonatomic) IBOutlet UILabel *eventDetailDateLabel;
@property (weak, nonatomic) IBOutlet UILabel *eventDetailDescriptionLabel;


- (IBAction)closeModalView:(id)sender;
- (IBAction)addEventToNative:(id)sender;


@end
Run Code Online (Sandbox Code Playgroud)

原来的.m

#import "EventoViewController.h"



@implementation EventoViewController

@synthesize eventDetailTitleLabel, eventDetailDateLabel, eventDetailDescriptionLabel;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    } …
Run Code Online (Sandbox Code Playgroud)

nscalendar ios ekevent

4
推荐指数
1
解决办法
3111
查看次数

iOS - 删除重复的EKEvent,事件再次出现

我在日历中有一个重复发生的事件.我使用此代码删除单个事件[store removeEvent:event span:EKSpanThisEvent commit:YES error:&errorThis];,此方法返回true但事件未从日历中删除.

objective-c ios ekevent ekeventkit ekeventstore

4
推荐指数
1
解决办法
1768
查看次数

如何使用 EKEventViewController 在我的应用程序中显示 EKEvent 邀请的详细信息?

简要总结

我希望我的应用程序的用户能够接受/拒绝他们日历的活动邀请。为此,我尝试使用 EventKitUI 组件启动事件,并允许用户在不离开我的应用程序的情况下更新事件。 问题是每当我将 EKEvent 分配给 EKEventViewController 时它就会崩溃

详细说明

我想要的是:

要显示类似于本机 iOS 日历中的视图,它应该如下所示:

在此处输入图片说明

我拥有的:

import UIKit
import EventKitUI

class CalendarViewController: UIViewController, EKEventViewDelegate, EKEventEditViewDelegate {

   var meetingID = "id"

   override func viewDidLoad() {
       super.viewDidLoad()
       //self.showEditEvent(meeting: meetingID)
       self.showInvite(meeting: meetingID)
   }

   func showInvite(meeting: Meeting){
        let evc = EKEventViewController()
        var event = EKEvent(eventStore: MeetingsFetcher.eventStoreClass)
        event = MeetingsFetcher.eventStoreClass.event(withIdentifier: meetingID)!
        evc.delegate = self 
        evc.event = event
        evc.allowsEditing = true
        evc.allowsCalendarPreview = true
        self.screen.present(evc, animated: true, completion: nil)
    }

    func eventViewController(_ controller: EKEventViewController, …
Run Code Online (Sandbox Code Playgroud)

calendar ios eventkit ekevent swift

4
推荐指数
1
解决办法
775
查看次数

requestAccessToEntityType:completion: 已被弃用,不再允许调用此方法。而是使用 requestFullAccessToEventsWithCompletion:

今天,我已将 Xcode 更新到 15.0,将 iPhone 更新到 iOS 17,但现在我在日历中写入 EKEvent 的代码不再起作用。它在早期版本的 iOS 中运行良好。我有兼容性问题还是还有其他原因?

错误是这样的:

Error: -requestAccessToEntityType:completion: has been deprecated-calling this method is no longer allowed. Instead, use -requestFullAccessToEventsWithCompletion:, -requestWriteOnlyAccessToEventsWithCompletion:, or -requestFullAccessToRemindersWithCompletion:

我的代码如下所示:

    func accesCalenderToAddEvent() {
        let eventStore: EKEventStore = EKEventStore()
        eventStore.requestAccess(to: EKEntityType.event) { granted, error in
            DispatchQueue.main.async {
                if (granted) && (error == nil) {
                    let event = EKEvent(eventStore: self.eventStore)
                    event.title = "Event 1"
                    event.startDate = Date()
                    event.endDate = Date()
                    
                    let eventController = EKEventEditViewController()
                    eventController.event = event
                    eventController.eventStore = eventStore
                    eventController.editViewDelegate …
Run Code Online (Sandbox Code Playgroud)

ios ekevent ekeventstore swift ios17

4
推荐指数
1
解决办法
1541
查看次数