I have a data matrix (of players) displayed in UICollectionView. I want the player information to be displayed in a popup view when the user touches the cell. I asked this question before and got it to work. But since then a strange problem has arisen.
When I touch the cell, a pop-up window appears, but the main view turns off two screens (!?), And the application crashes with this error: "The application terminated due to the unselected exception" NSGenericException ", reason: '- [UIPopoverController dealloc] reached while popover is still displayed.
PlayerDataView is built into the storyboard. I declared both the playerDataView controller and the popover view controller as properties of the collection view in its header file:
@property (strong, nonatomic) UIPopoverController *playerDataPopover;
@property (strong, nonatomic) SWSPlayerDataViewController *playerDataView;
Here is the code that creates the popover instance:
- (IBAction)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0 || indexPath.section == 0) {
return;
}
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
CGRect anchorRect = [collectionView layoutAttributesForItemAtIndexPath:indexPath].frame;
self.playerDataView = [self.storyboard instantiateViewControllerWithIdentifier:@"playerDataView"];
self.playerDataView.player = self.players[indexPath.section][indexPath.row];
self.playerDataPopover = [[UIPopoverController alloc] initWithContentViewController:self.playerDataView];
[self.playerDataPopover presentPopoverFromRect:anchorRect inView:self.collectionView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
I can understand why I get this error if there is a promotion from the collection view, but I can not understand why the unwinding occurs. Any ideas?
source
share