嗨我做了一个按钮,让你添加一个日历活动,但我希望在12小时的时钟上获取日期,并在上午和下午之间用一个按钮切换。
以下是日历活动的代码:
- (IBAction)agregaevento:(id)sender {
NSString *d1 = dia.text;
NSString *m1 = mes.text;
NSString *a1 = anio.text;
NSString *h1 = hora.text;
NSString *m2 = minutos.text;
NSString *fechadelevento = [NSString stringWithFormat:@"%@-%@-%@ %@:%@", d1, m1, a1,h1,m2];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"America/Montevideo"]];
[dateFormatter setDateFormat:@"dd-MMM-yyyy hh:mm"];
[Dateevento addObject:fechadelevento];
NSDate *myDate=[dateFormatter dateFromString:fechadelevento];
EKEventStore *store = [[EKEventStore alloc]init];
EKEventStore *eventStore = [[EKEventStore alloc] init];
EKEvent *myEvent = [EKEvent eventWithEventStore:store];
myEvent.title = ddText.text;
myEvent.startDate = myDate;
myEvent.endDate = myDate;
[myEvent setCalendar:[eventStore defaultCalendarForNewEvents]];
NSError *err;
[store saveEvent:myEvent span:EKSpanThisEvent error:&err];
}