从UICollectionView造成退卷酥料饼的看法(Popover view from UICo

2019-10-29 20:37发布

我的数据(玩家)的矩阵显示的UICollectionView 。 我想对一个球员的细节在酥料饼的视图当用户触摸单元格中显示。 我问这个问题前面 ,并得到它的工作。 但此后,一个奇怪的问题制定。

当我触摸一个细胞,出现酥料饼,但主要观点解开两个屏幕和应用程序崩溃,出现此错误:“由于未捕获的异常终止应用程序‘NSGenericException’,原因是:”(!?) - [UIPopoverController的dealloc]达到,而酥料饼仍然可见。”

该playerDataView是建立在故事板。 我宣布双方playerDataView控制器和酥料饼的视图控制器作为其头文件集合视图的属性:

@property (strong, nonatomic) UIPopoverController *playerDataPopover;
@property (strong, nonatomic) SWSPlayerDataViewController *playerDataView;

下面是实例化酥料饼的代码:

- (IBAction)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0 || indexPath.section == 0) {  // Ignores user selecting row or column headers that I've placed in the collection view data
        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]; // Sets player data in popover view.
    self.playerDataPopover = [[UIPopoverController alloc] initWithContentViewController:self.playerDataView];
    [self.playerDataPopover presentPopoverFromRect:anchorRect inView:self.collectionView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}

我能理解为什么我会得到这个错误,如果有从集合视图开卷,但我不明白,为什么开卷发生。 有任何想法吗?

Answer 1:

您可以在您的视图控制器的dealloc方法解雇你的酥料饼避免酥料饼的dealloc例外。

你开卷SEGUE可能是建立在你的故事板,你只需要找到并删除它。 你可以尝试设置一个断点prepareForSegue:看如果任一或通过SEGUE对象中的堆栈跟踪有给你任何线索。



文章来源: Popover view from UICollectionView causing unwind