xcode 如何使用我们的 iphone 应用程序在 iPhone 日历应用程序中添加事件。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6139058/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add Events in iPhone calendar application using our iphone application.
提问by user532445
How to add Event in iPhone Calendar. I just want to add events in iPhone calendar using my application and wants to set pushnotification for perticuler event. Please help me out on this. Thank you.
如何在 iPhone 日历中添加事件。我只想使用我的应用程序在 iPhone 日历中添加事件,并想为 perticuler 事件设置推送通知。请帮我解决这个问题。谢谢你。
回答by octy
To create an Event programmatically, you would use EventKit, more specifically the provided EKEventEditViewController
. See the Apple documentation for an explanation and sample code.
要以编程方式创建事件,您将使用 EventKit,更具体地说是提供的EKEventEditViewController
. 有关说明和示例代码,请参阅 Apple 文档。
In iOS 4.0+, you would also be able to access that controller without writing any EventKit code. To do that, use a UITextView
configured with dataDetectorTypes = UIDataDetectorTypeCalendarEvent
. The UITextView will automatically convert strings representing formatted dates, days of the week, etc. - to clickable URLs that handle the creation of events.
在 iOS 4.0+ 中,您还可以在不编写任何 EventKit 代码的情况下访问该控制器。为此,请使用UITextView
配置为dataDetectorTypes = UIDataDetectorTypeCalendarEvent
. UITextView 将自动将表示格式化日期、星期几等的字符串转换为处理事件创建的可点击 URL。
Please refer to the Apple iOS documentation for the rest of your question. If there is anything specific that doesn't work in your case, please post some code, show us what you have tried already, etc.
有关您的其余问题,请参阅 Apple iOS 文档。如果有任何特定的东西在您的情况下不起作用,请发布一些代码,向我们展示您已经尝试过的内容等。
回答by Jean
you can use this code
你可以使用这个代码
EKEventStore *es = [[EKEventStore alloc] init];
EKEventEditViewController *controller = [[EKEventEditViewController alloc] init];
controller.eventStore = es;
controller.editViewDelegate = self;
[self presentModalViewController:controller animated:YES];
[controller release];