Кнопка к событию в календаре - PullRequest
0 голосов
/ 07 марта 2012

Я хотел бы создать кнопку, которая добавляет событие в календарь на iPhone.

Пример:

Нажмите эту кнопку, и в вашем календаре будет событие, показывающее, в какое времяи дата Суперкубок есть.(Или что-то еще)

Надеюсь, что некоторые могут помочь мне.

Спасибо

Ответы [ 2 ]

1 голос
/ 06 ноября 2012
add 2 frameworks
1.EventKitUI.framework
2.EventKit.framework

.m
#import <EventKitUI/EventKitUI.h>

- (IBAction)CreateEvent:(id)sender {

    //Get the even store object
    //EKEventStore *eventStore = [[EKEventStore alloc] init];
    EKEventStore *eventStore = [[EKEventStore alloc] init];

    /* iOS 6 requires the user grant your application access to the Event Stores */


     if([[UIDevice currentDevice].systemVersion floatValue] >= 6.0)// checks if device is ios6
       {
    [eventStore requestAccessToEntityType:EKEntityTypeReminder completion:^(BOOL granted, NSError *error) {
        // handle access here
    }];





    if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
    {
        // iOS Settings > Privacy > Calendars > MY APP > ENABLE | DISABLE 
        [eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
         {
             if ( granted )
             {
                 NSLog(@"User has granted permission!");
             }
             else
             {
                 NSLog(@"User has not granted permission!");
             }
         }];
    }



           EKEventEditViewController *controller=[[EKEventEditViewController alloc]init];


           controller.eventStore=eventStore;
           controller.editViewDelegate=self;
           controller.wantsFullScreenLayout=YES;
           [self presentModalViewController:controller animated:YES];

    }


    else
    {


    EKEventEditViewController *controller=[[EKEventEditViewController alloc]init];


    controller.eventStore=eventStore;
    controller.editViewDelegate=self;
    controller.wantsFullScreenLayout=YES;
    [self presentModalViewController:controller animated:YES];

    }
}



- (void)eventEditViewController:(EKEventEditViewController *)controller didCompleteWithAction:(EKEventEditViewAction)action
{
  //  [Bw alert:@"Done"];


    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@" Done" message:@"Event Sucessfully Saved " delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
    [alert show];

    [self dismissModalViewControllerAnimated:YES];

}





@end
0 голосов
/ 07 марта 2012

Существует много разных маршрутов для достижения одного и того же результата, но хорошим началом может стать это руководство , которое объясняет один из способов сделать именно это.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...