I have a list of calendar events in my iOS application that should be open in EKEventViewController when clicked. Here is my code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
EKEventViewController *eventViewController = [EKEventViewController new];
eventViewController.event = [self.events objectAtIndex:[indexPath row]];
[self presentViewController:eventViewController animated:YES completion:nil];
}
The type of events is correctly displayed at the bottom of the screen, but I have no way to return to the list of events!
I use a navigation controller (but not a navigation bar!), So adding this code allowed me to return to the list:
-(void)viewDidAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
EKEventViewController *eventViewController = [EKEventViewController new];
eventViewController.event = [self.events objectAtIndex:[indexPath row]];
[self.navigationController setNavigationBarHidden:NO];
[self.navigationController pushViewController:eventViewController animated:YES];
}
But this solution is not very elegant, because when I click the "Back" button in the event view, the navigation bar is not deleted (it is displayed on top of my list of events) before the entire view of the events leaves the screen.
? - , ( ), .
:
:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
EKEventViewController *eventViewController = [EKEventViewController new];
eventViewController.event = [self.events objectAtIndex:[indexPath row]];
eventViewController.delegate = self;
UINavigationController *navBar = [[UINavigationController new] initWithRootViewController:eventViewController];
[self presentViewController:navBar animated:YES completion:nil];
}
- (void)eventViewController:(EKEventViewController *)controller didCompleteWithAction:(EKEventViewAction)action
{
[self dismissViewControllerAnimated:YES completion:nil];
}