Like others coming to iOS8, I'm getting the warning:
Presenting view controllers on detached view controllers is discouraged <EditItineraryViewController: 0x7ca56e00>.
This is caused by the following code:
- (void)editActivityDetailsForIndexPath:(NSIndexPath *)indexPath {
NSPredicate *predicateForDisplay = [[NSPredicate alloc] init];
switch (indexPath.section) {
case kIncompleteActivitiesSection:
predicateForDisplay = _predIncomplete;
break;
case kCompleteActivitiesSection:
predicateForDisplay = _predComplete;
break;
default:
break;
}
NSString *theActivityName = [[NSString alloc] init];
theActivityName = [[[_activitiesArray filteredArrayUsingPredicate:predicateForDisplay] objectAtIndex:indexPath.row] activityName];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ActivityDetailViewController *activityDetailVC = [storyboard instantiateViewControllerWithIdentifier:@"ActivityDetailView"];
activityDetailVC.modalPresentationStyle = UIModalPresentationFormSheet;
activityDetailVC.delegate = self;
// send the activity to the view
activityDetailVC.theActivity = [[_activitiesArray filteredArrayUsingPredicate:predicateForDisplay] objectAtIndex:indexPath.row];
// configure the look of the view
_activityDetailsPopover = [[UIPopoverController alloc] initWithContentViewController:activityDetailVC];
_activityDetailsPopover.delegate = self;
ItineraryCell *cell = (ItineraryCell *)[self.itineraryTableView cellForRowAtIndexPath:indexPath];
activityDetailVC.contentView.backgroundColor = [UIColor whiteColor];
activityDetailVC.navigationBar.barTintColor = _colorSchemeLightColor;
activityDetailVC.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:_colorSchemeColor};
activityDetailVC.saveButton.tintColor = _colorSchemeColor;
activityDetailVC.cancelButton.tintColor = _colorSchemeColor;
activityDetailVC.labelB.textColor = _colorSchemeColor;
activityDetailVC.labelM.textColor = _colorSchemeColor;
activityDetailVC.activityTitle.textColor = _colorSchemeColor;
activityDetailVC.activityTitle.font = [UIFont boldSystemFontOfSize:17.0];
// present the view
[_activityDetailsPopover presentPopoverFromRect:cell.cellDetailsButton.frame inView:cell.cellDetailsButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
This is an iPad app and in this case, the popover is being presented in such a way as to have its little pointer pointing at an "i" icon that sits on a tableview cell in a tableview.
This works in three other places in my app without causing the warning at all. But for some reason, with this implementation, it's causing the warning. The weird thing is, this was the first place in my app I used this means of presenting the popover from a tableview cell and the other instances are just copies of this code!
Any ideas what I can look at to figure out where the hierarchy is buggered up? Is it related to how the tableview cell is being generated and then this popover presented on top of it, or does it have to do strictly with the popover itself? Or could it have to do with the tableview. I don't even know where to start to look.
Thanks so much!