我有一個顯示在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];
}
我可以理解爲什麼如果從收集視圖中放鬆,我會得到該錯誤,但我無法弄清楚爲什麼放鬆正在發生。有任何想法嗎?
只有在設置完成後纔會發生放鬆繼續。如果你不知道你告訴你的應用程序在哪裏執行這個放大縮小(所以你可以撤消它),那麼你可能需要從頭開始這個視圖控制器... – nhgrif