2014-03-01 77 views
0

我有一個顯示在UICollectionView中的數據矩陣(玩家)。當用戶觸摸單元格時,我需要在彈出視圖中顯示玩家的細節。我asked this question earlier並得到它的工作。但從那時起,一個奇怪的問題就出現了。從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]; 
} 

我可以理解爲什麼如果從收集視圖中放鬆,我會得到該錯誤,但我無法弄清楚爲什麼放鬆正在發生。有任何想法嗎?

+0

只有在設置完成後纔會發生放鬆繼續。如果你不知道你告訴你的應用程序在哪裏執行這個放大縮小(所以你可以撤消它),那麼你可能需要從頭開始這個視圖控制器... – nhgrif

回答

0

通過在視圖控制器的dealloc方法中關閉彈出窗口,可以避免彈出窗口dealloc異常。

您的展開segue可能設置在您的故事板中,您只需要查找並刪除它即可。您可以嘗試在prepareForSegue:上設置一個斷點,以查看傳入的segue對象或其中的堆棧跟蹤是否提供了任何線索。

+0

好主。我發誓從集合視圖單元中尋找一個放鬆的繼續,但直到我現在重新檢查纔看到它。對於這個虛擬問題感到抱歉,並感謝回覆... – Henry95