This is my first post because I usually find all the answers on stack overflow but not this time !
I have a little problem.
I am using the following methods :
-(void)scrollToTop;
{
[_scrollView setContentOffset:CGPointZero animated:YES];
}
sometimes it animates sometimes not !
This one works :
-(void)newPage:(NSString*)href
{
if(!(_pageNumber == href.integerValue))
{
__weak id weakSelf = self;
[(PageViewController*)_preLoadPages[href] setPageMinHeight:_actualPage.height];
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
viewControllers[0] = _preLoadPages[href];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished){
[weakSelf afterLinkClicked:href];
}];
_pageNumber = href.integerValue;
}
}
- (void)afterLinkClicked:(NSString*)href
{
_pageNumber = href.integerValue;
[_preLoadPages[href] setPageMinHeight:0];
_actualPage = _preLoadPages[href];
[_preLoadPages removeAllObjects];
[self updateScrollView];
[self scrollToTop];
[self parsePage];
}
Whereas this one does not :
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint test = [gestureRecognizer locationInView:gestureRecognizer.view];
if(test.x>=742)
{
if(_preLoadPages[#"next"]!=nil)
{
__weak id weakSelf = self;
[(PageViewController*)_preLoadPages[#"next"] setPageMinHeight:_actualPage.height];
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
viewControllers[0] = _preLoadPages[#"next"];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished){
[weakSelf afterAnimationCompleted];
}];
}
}
return YES;
}
- (void)afterAnimationCompleted
{
_pageNumber++;
[_preLoadPages[#"next"] setPageMinHeight:0];
_actualPage = _preLoadPages[#"next"];
[_preLoadPages removeAllObjects];
[self updateScrollView];
[self scrollToTop];
[self parsePage];
}
There is practically no differences between these two calls !
I have tried to use performSelector: withObject: withDelay:0 but it doesn't work too !!
Related
Any one know how to reload collectionView in parentViewController when removing childViewController.
Here, I am processing on click of button adding childViewController and on click of that childViewController I am getting data and that data will transferred to parentViewController after that child view get's remove from parentViewController.
I am getting data from childViewController, also reloading collection view.
dispatch_async(dispatch_get_main_queue(),^{
[self.view layoutIfNeeded];
[self.collectionViewcellItem layoutIfNeeded];
[self.collectionViewcellItem reloadData];
});
but, no effect of reloading here seen.
means not able to change parentviewconroller view after removal of childViewController.
Thank you
Waiting for the answer and yes I am doing it in objective c.
parentViewController file.
[self.view addSubview:filterMenuVC.view];
filterMenuVC.view.backgroundColor = [UIColor clearColor];
[self addChildViewController:filterMenuVC];
[self.view addSubview:filterMenuVC.view];
[self animationSideFilterMenuBarOpen];
[filterMenuVC didMoveToParentViewController:self];
childViewController file
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"%#",[NSString stringWithFormat:#"%ld",(long)indexPath.row]);
// // [wel animationSideFilterMenuBarClose];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
int categoryId = (int)cell.textLabel.tag;
[self animationSideMainMenuBarClose:categoryId];
}
-(void)animationSideMainMenuBarClose:(int)categoryId{
CGFloat width = [UIScreen mainScreen].bounds.size.width;
self.view.frame = CGRectMake(width - self.view.frame.size.width, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
[UIView animateWithDuration:0.5 animations:^{
self.view.frame = CGRectMake(width, self.view.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
}
completion:^(BOOL finished){
[self.view removeFromSuperview];
self.view = nil;
NSLog(#"category id Filter: %d",categoryId);
BOOL boolresponse = [wel getUserWork:categoryId];
if (boolresponse == NO) {
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:#""
message:#"No internet connection"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okButton = [UIAlertAction
actionWithTitle:#"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:okButton];
[self presentViewController:alert animated:YES completion:nil];
}
}];
}
here, BOOL boolresponse = [wel getUserWork:categoryId]; getUserWork is the function in parentViewController, I call that and removing the childViewController. get correct data but not able to reload collectionView.
parentViewFunction which I am calling.
-(BOOL)getUserWork:(int)catergoryId{
appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[self dismissViewControllerAnimated:true completion:^{
//do whatever you do here
[self.collectionViewcellItem reloadData];
}];
categoryIdStart = catergoryId;
Reachability *r = [[Reachability alloc]init];
if(r.currentReachabilityStatus != NotReachable) {
return NO;
}
else
{
[SVProgressHUD show];
[SVProgressHUD setStatus:#"Loading..."];
[SVProgressHUD setRingRadius:20];
[SVProgressHUD setRingThickness:10];
[SVProgressHUD setBorderColor:[UIColor orangeColor]];
[SVProgressHUD setBorderWidth:0.5];
[SVProgressHUD setForegroundColor:[UIColor orangeColor]];
NSLog(#"id category: %d",categoryIdStart);
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:[appDelegate.UserDic valueForKey:#"token"],#"token",[appDelegate.UserDic valueForKey:#"id"],#"id_user",[NSString stringWithFormat:#"%d",categoryIdStart],#"id_category",nil];
NSMutableArray *postArray = [NSMutableArray array];
[params enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *obj, BOOL *stop) {
[postArray addObject:[NSString stringWithFormat:#"%#=%#", key, [apiCall percentEscapeString:obj]]];
}];
NSString *postString = [postArray componentsJoinedByString:#"&"];
[apiCall apiType:#"xyzzy" pD:postString dataRetrive:^(NSDictionary *dictionary){
int status = [[dictionary valueForKey:#"status"] intValue];
if (status == 0) {
[SVProgressHUD dismiss];
dispatch_async(dispatch_get_main_queue(),^{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:#""
message:[dictionary valueForKey:#"msg"]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okButton = [UIAlertAction
actionWithTitle:#"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:okButton];
[self presentViewController:alert animated:YES completion:nil];
});
}
else{
[SVProgressHUD dismiss];
[cacheImage removeAllObjects];
dic = [dictionary valueForKey:#"data"];
NSLog(#"Category detail: %# %lu",dic,(unsigned long)dic.count);
NSLog(#"image category %# :",[dic valueForKey:#"category_name"]);
dispatch_async(dispatch_get_main_queue(),^{
[self.view layoutIfNeeded];
[self.collectionViewcellItem layoutIfNeeded];
[self.collectionViewcellItem reloadData];
[self viewWillAppear:true];
});
}
}];
return YES;
}
}
I am developing an app.I have a problem while developing the app.
The problem is:
I have a UIImageView and audio.I have 20 images in an array .so i need to display the 20 images in this UIImageView within time interval.Along with the image i need to set the audio.I need to view in same time, ie 20 images and audio should come at same time.
my code as below.
alphabetsStoreArray = [[NSMutableArray alloc]initWithObjects:#"a.png",#"b.png",#"c.png",#"d.png",#"e.png",#"f.png",#"g.png",#"h.png",#"i.png",#"j.png",#"k.png",#"l.png",#"m.png",#"n.png",#"o.png",#"p.png",#"q.png",#"r.png",#"s.png",#"t.png",#"u.png",#"v.png",#"w.png",#"x.png",#"y.png",#"z.png", nil];
commonFunctionObject = [[SpeechCommonFunctions alloc]init];
commonFunctionObject.isRecordComplete = NO;
counter = 0;
isMicPresent = YES;
_confirmationPopupView.hidden = true;
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:#selector(repeatActionFire) userInfo:nil repeats:NO];
// Do any additional setup after loading the view.
}
-(void)repeatActionFire
{
if(counter >= alphabetsStoreArray.count)
{
NSLog(#"finished");
[_alphabetsShowImageView removeFromSuperview];
[_speakerOrMicImageView removeFromSuperview];
UIImageView *congratzView = [[UIImageView alloc]initWithFrame:self.view.frame];
congratzView.image = [UIImage imageNamed:#"congratulation.png"];
[self.view addSubview:congratzView];
[self performSelector:#selector(navNew) withObject:nil afterDelay:3];
}
else
{
[commonFunctionObject textToSpeechAction:alphabetsStoreArray :counter :_alphabetsShowImageView :_speakerOrMicImageView :isMicPresent];
[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:#selector(ActionToCkeckRecordCompletion) userInfo:nil repeats:YES];
}
}
-(void)ActionToCkeckRecordCompletion
{
if(commonFunctionObject.isRecordComplete)
{
_confirmationPopupView.hidden = false;
}
}
-(void)navNew
{
v11=[self.storyboard instantiateViewControllerWithIdentifier:#"maincontroller"];
[self presentViewController:v11 animated:NO completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
} */
-(IBAction)homebut:(id)sender{
UIAlertController * alert=[UIAlertController alertControllerWithTitle:#"Title"
message:#"Message"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* Home = [UIAlertAction
actionWithTitle:#"RETURN TO HOME"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
v11=[self.storyboard instantiateViewControllerWithIdentifier:#"maincontroller"];
[self presentViewController:v11 animated:NO completion:nil];
}];
UIAlertAction* Cancel = [UIAlertAction
actionWithTitle:#"CANCEL"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
}];
[alert addAction:Cancel];
[alert addAction:Home];
[self presentViewController:alert animated:YES completion:nil];
}
- (IBAction)playButtonAction:(id)sender
{
[commonFunctionObject recordPlayAction];
}
- (IBAction)nextButtonAction:(id)sender
{
counter+=1;
_confirmationPopupView.hidden = true;
commonFunctionObject.isRecordComplete = NO;
if(commonFunctionObject.player.playing){[commonFunctionObject.player stop];}
[self repeatActionFire];
}
- (IBAction)retryButtonAction:(id)sender
{
_confirmationPopupView.hidden = true;
commonFunctionObject.isRecordComplete = NO;
if(commonFunctionObject.player.playing){[commonFunctionObject.player stop];}
[self repeatActionFire];
}
how to do?
Try this, May be you need more than this, but here is a start to get you in the right direction.
-(IBAction)btnclicked:(id)sender {
NSMutableArray *images = [[NSMutableArray alloc]init];
//all alloc does is allocate memory. The -init method is crucial to
actually initialize the object into a working state.
for (int imagenumber = 1; imagenumber <= 45; imagenumber++) {
NSMutableString *myString = [NSMutableString stringWithFormat:#"%i.png", imagenumber];
[images addObject:[UIImage imageNamed:myString]];
}
CGRect frame = CGRectMake(0.0, 0.0, 320, 460);
UIImageView *imageview = [[UIImageView alloc] initWithFrame:frame];
imageview.contentMode = UIViewContentModeScaleToFill;
NSURL *url = [NSURL fileURLWithPath:[NSString
stringWithFormat:#"%#/giggity stick around.wav", [[NSBundle mainBundle]
resourcePath]]];
soundPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url
error:nil];
soundPlayer.volume = 1;
[soundPlayer play];
imageview.animationImages = images;
imageview.animationDuration = 3.2;
imageview.animationRepeatCount = 1;
[imageview startAnimating];
[self.view addSubview:imageview];
}
Use the AVFoundation to play the audio.
This problem, when i swipe screen API Calls are to be made, separate calls for separate swipe i.e. Left, Right, Top, Bottom. Also there has to be Stop API which has to be sent in 1 minute delay of swipe.
Example Camera moving on swipe for 1 second and stops:
Swipe Left -> Left() GET API is called with AFNetworking -> (So Camera starts moving to left) -> Soon after Left API is triggered -> 1 second delay -> Stop GET API is called with AFNetworking. Repeats same method for Right(), Top(), Bottom()
I am not able to achieve this smoothly, I use this logic.
- (void)didSwipe:(UISwipeGestureRecognizer*)swipe{
if (swipe.direction == UISwipeGestureRecognizerDirectionLeft) {
[self performSelector:#selector(moveRight) withObject:self afterDelay:0.0];
[self performSelector:#selector(stop:) withObject:self afterDelay:1.0];
} else if (swipe.direction == UISwipeGestureRecognizerDirectionRight) {
[self performSelector:#selector(moveLeft) withObject:self afterDelay:0.0];
[self performSelector:#selector(stop:) withObject:self afterDelay:1.0];
} else if (swipe.direction == UISwipeGestureRecognizerDirectionUp) {
[self performSelector:#selector(moveDown) withObject:self afterDelay:0.0];
[self performSelector:#selector(stop:) withObject:self afterDelay:1.0];
} else if (swipe.direction == UISwipeGestureRecognizerDirectionDown) {
[self performSelector:#selector(moveUp) withObject:self afterDelay:0.0];
[self performSelector:#selector(stop:) withObject:self afterDelay:1.0];
}
}
This are Method calls
-(void) moveRight
{
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:#"MoveRight" forKey:#"direction"];
[self changeDirection:parameters];
}
-(void) moveLeft
{
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:#"MoveLeft" forKey:#"direction"];
[self changeDirection:parameters];
}
-(void) moveUp
{
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:#"MoveUp" forKey:#"direction"];
[self changeDirection:parameters];
}
-(void) moveDown
{
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:#"MoveDown" forKey:#"direction"];
[self changeDirection:parameters];
}
-(void) stop
{
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:#"Stop" forKey:#"direction"];
[self changeDirection:parameters];
}
Now ChangeDirection Method
-(void) changeDirection:(NSDictionary *) parameters
{
dispatch_queue_t myQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(myQueue, ^{
[RestHandler afnetworkingGetApiCall():parameters :^(id response, NSString *respMsg)
{
}];
dispatch_async(dispatch_get_main_queue(), ^{
});
});
}
Hope I am able to explain my question. Let me know if its not clear
Cheers.
i think, you have to create model for each response. then for each call you have to create common operation queue.
I'm a newbie on coding in objective-c.
I'm currently making an exercise application where I need to get some json-data from an API with a NSURLSession and send the date to a PageViewController.
So currently I'm getting my json-data in the method 'getWeer',which I call before making the pageViewController (in viewDidLoad). But because the NSURLSession runs async I think and isn't complete, the json-data always is null when I try to access it in my pageViewController.
How can I make the pageViewController after the NSURLSession is complete?
#interface SecondViewController ()<CLLocationManagerDelegate>
#property (nonatomic, strong) CLLocationManager *locationManager;
#property (nonatomic, strong) NSString *AppId;
#property (nonatomic, weak) NSDictionary *json;
#end
#implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.AppId = #"feda1f13263bb730deeb89fb3936a76e";
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[[self locationManager] requestWhenInUseAuthorization];
[[self locationManager] startUpdatingLocation];
[self getWeer];
// Create page view controller
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"PageViewController"];
self.pageViewController.dataSource = self;
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = #[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 30);
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (PageContentViewController *)viewControllerAtIndex:(NSUInteger)index{
// Create a new view controller and pass suitable data.
PageContentViewController *pageContentViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"PageContentViewController"];
pageContentViewController.pageIndex = index;
NSLog(#"%#",self.json);
pageContentViewController.json = self.json;
return pageContentViewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
NSUInteger index = ((PageContentViewController*) viewController).pageIndex;
if ((index == 0) || (index == NSNotFound)) {
return nil;
}
index--;
return [self viewControllerAtIndex:index];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
NSUInteger index = ((PageContentViewController*) viewController).pageIndex;
if (index == NSNotFound) {
return nil;
}
index++;
if (index == 3) {
return nil;
}
return [self viewControllerAtIndex:index];
}
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController{
return 3;
}
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController{
return 0;
}
-(void)getWeer{
NSString *dataUrl = [NSString stringWithFormat:#"http://api.openweathermap.org/data/2.5/forecast/daily?lat=%f&lon=%f&cnt=4&&APPID=%#&units=metric&lang=nl", self.locationManager.location.coordinate.latitude, self.locationManager.location.coordinate.longitude, self.AppId];
NSLog(#"%f",self.locationManager.location.coordinate.latitude);
NSLog(#"%f",self.locationManager.location.coordinate.longitude);
NSURL *url = [NSURL URLWithString:dataUrl];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
self.json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
});
}];
[dataTask resume];
}
#end
Call this method after async finish.
// Create page view controller
-(void)setupPageViewController {
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"PageViewController"];
self.pageViewController.dataSource = self;
PageContentViewController *startingViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = #[startingViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
self.pageViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 30);
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
}
So I present an EKEventViewController with a UINavigationController. From inside the EKEventViewController I am able to edit the event. It presents an EKEventEditViewController. Everything thing works great(cancel/done buttons) except when I delete the event inside the EKEventEditViewController I recieve this
attempt to dismiss modal view controller whose view does not currently appear. self = modalViewController =
Here is my code...
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[CalendarViewController connectExchange];
if (connectionEx == YES)
{
NSDate *dateRepresentingThisDay = [self.sortedDays objectAtIndex:indexPath.section];
NSArray *eventsOnThisDay = [self.sections objectForKey:dateRepresentingThisDay];
EKEventViewController *eventViewController = [[EKEventViewController alloc] init];
eventViewController.allowsEditing = YES;
eventViewController.delegate = self;
EKEvent *event = [eventsOnThisDay objectAtIndex:indexPath.row];
eventViewController.event = event;
UINavigationController *navBar = [[UINavigationController alloc]initWithRootViewController:eventViewController];
[self.navigationController presentViewController:navBar animated:YES completion:nil];
}
}
- (void)eventViewController:(EKEventViewController *)controller didCompleteWithAction:(EKEventViewAction)action
{
EKEvent *event = controller.event;
CalendarViewController * __weak weakSelf = self;
// Dismiss the modal view controller
[self dismissViewControllerAnimated:YES completion:^
{
if (action == EKEventViewActionDone)
{
dispatch_async(dispatch_get_main_queue(), ^{
NSError *err;
[self.eventStore saveEvent:event span:EKSpanThisEvent error:&err];
[self updateEvent:event];
});
}
if (action == EKEventViewActionDeleted)
{
dispatch_async(dispatch_get_main_queue(), ^{
[self deleteEvent:event];
NSError *error;
EKEvent *eventRemove = [self.eventStore eventWithIdentifier:event.eventIdentifier];
[self.eventStore removeEvent:eventRemove span:EKSpanThisEvent error:&error];
});
}
if (action == EKEventViewActionResponded)
{
dispatch_async(dispatch_get_main_queue(), ^{
});
}
weakSelf.eventsList = [self fetchEvents];
[weakSelf.tableView reloadData];
NSLog(#"Event Updated");
}];
}
How am I suppose to properly dismiss the ViewControllers after deleting the event via the EKEventEditViewController?
I solved my problem by subclassing EKEventViewController and setting up EKEventEditViewDelegate and EKEventViewDelegate.
Here is my changed didSelectRow(CalendarViewController.m),
EditViewController *eventViewController = [[EditViewController alloc] init];
eventViewController.allowsEditing = YES;
eventViewController.delegate = self;
EKEvent *event = [eventsOnThisDay objectAtIndex:indexPath.row];
eventViewController.event = event;
[self.navigationController pushViewController:eventViewController animated:YES];
self.editingEvent = eventViewController.event;
The EditViewController is my subclass of EKEventViewController.
In the subclass(EditViewController.m) I added my own edit button with a selector in viewDidLoad,
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self.delegate action:#selector(editCalEvent)];
self.navigationItem.rightBarButtonItem = editItem;
}
Now back in CalendarViewController.m after adding the EKEventEditViewDelegate and EKEventViewDelegate to the #interface I added new methods
- (void)editCalEvent
{
EKEventEditViewController *editController = [[EKEventEditViewController alloc] init];
editController.event = self.editingEvent;
editController.eventStore = self.eventStore;
editController.editViewDelegate = self;
[self presentViewController:editController animated:YES completion:nil];
}
- (void)eventEditViewController:(EKEventEditViewController *)controller didCompleteWithAction (EKEventEditViewAction)action
{
EKEvent *thisEvent = controller.event;
[self dismissViewControllerAnimated:NO completion:^
{
switch (action)
{
{case EKEventEditViewActionCanceled:
//NSLog(#"Canceled action");
break;}
{case EKEventEditViewActionSaved:
[self.eventStore saveEvent:thisEvent span:EKSpanThisEvent error:nil];
[self updateEvent:thisEvent];
break;}
{case EKEventEditViewActionDeleted:
[self deleteEvent:thisEvent];
NSError *error;
EKEvent *eventRemove = [self.eventStore eventWithIdentifier:thisEvent.eventIdentifier];
[self.eventStore removeEvent:eventRemove span:EKSpanThisEvent error:&error];
//NSLog(#"Deleted action");
break;}
{default:
break;}
}
}];
}
- (void)eventViewController:(EKEventViewController *)controller didCompleteWithAction:(EKEventViewAction)action
{
}
Use the editViewDelegate instead of delegate.