I have several UIPopover
s in my app that contain UITableView
s. All send the message popoverControllerDidDismissPopover:
when they are dismissed. When a particular popover is dismissed, I want to take all of the user's selections and move them to a UITextView
.
I can't do this unless I know which popover is being dismissed. Any ideas how I can accomplish this?
UIViewController* popoverContent = [[UIViewController alloc] init];
UIView *popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 416)]; // was 216
popoverView.backgroundColor = [UIColor redColor];
popoverContent.contentSizeForViewInPopover = CGSizeMake(300.0, 416.0);
// define UITableView
tvServices = [[UITableView alloc] init];
tvServices.frame = CGRectMake(0, 0, 300, 416);
tvServices.tag = 1201;
tvServices.delegate = self;
tvServices.dataSource = self;
// add it to the popover
[popoverView addSubview:tvServices];
popoverContent.view = popoverView;
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
popoverController.delegate = (id)self;
[popoverController setPopoverContentSize:CGSizeMake(300, 416) animated:NO];
// show it next to services textbox
[popoverController presentPopoverFromRect:soServices.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
}
The popoverControllerDidDismissPopover:
delegate method tells you which popover is being dismissed. From there you can look at the popover's contentViewController
as needed.
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
UITableViewController *controller = (UITableViewController *)popoverController.contentViewController;
UITableView *tableView = controller.tableView;
}
This should point you in the right directory. But you shouldn't need access to the table view. You be accessing the data from the view controller, not the table view.