ios - How to dismiss the eventeditviewcontroller when I have allowed editing on eventviewcontroller? -



ios - How to dismiss the eventeditviewcontroller when I have allowed editing on eventviewcontroller? -

so nowadays ekeventviewcontroller uinavigationcontroller. within ekeventviewcontroller able edit event. presents ekeventeditviewcontroller. thing works great(cancel/done buttons) except when delete event within ekeventeditviewcontroller recieve

attempt dismiss modal view controller view not appear. self = modalviewcontroller =

here 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 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 suppose dismiss viewcontrollers after deleting event via ekeventeditviewcontroller?

i solved problem subclassing ekeventviewcontroller , setting ekeventeditviewdelegate , ekeventviewdelegate.

here 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 subclass of ekeventviewcontroller.

in subclass(editviewcontroller.m) added own edit button selector in viewdidload,

- (void)viewdidload { [super viewdidload]; uibarbuttonitem *edititem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemedit target:self.delegate action:@selector(editcalevent)]; self.navigationitem.rightbarbuttonitem = edititem; }

now in calendarviewcontroller.m after adding ekeventeditviewdelegate , ekeventviewdelegate @interface 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 { }

ios objective-c viewcontroller dismiss ekevent

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -