my app stores different attributes in Core Data objects. They are all shown in a UITableView, if you click a cell, a DetailView is shown. the usual stuff like in the Master-
Base on Dheeraj's reply, adjust some code to rectify the wrong touch location of tableview cell. Assume we need pass the value named type to destination controller.
- (nullable UIViewController *)previewingContext:(id )previewingContext viewControllerForLocation:(CGPoint)location{
// check if we're not already displaying a preview controller
if ([self.presentedViewController isKindOfClass:[DetailViewController class]]) {
return nil;
}
CGPoint cellPostion = [self.tableview convertPoint:location fromView:self.view];
NSIndexPath *path = [self.tableview indexPathForRowAtPoint:cellPostion];
if (path) {
UITableViewCell *cell = [self.tableview cellForRowAtIndexPath:path];
type = [[self.data objectAtIndex:path.row] integerValue];
// shallow press: return the preview controller here (peek)
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
DetailViewController *previewController = [storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
previewController.type = type;
previewingContext.sourceRect = [self.view convertRect:cell.frame fromView:self.tableview];
return previewController;
}
return nil;
}