【发布时间】:2018-02-01 17:42:16
【问题描述】:
我正在尝试显示指向UICollectionViewCell 的详细视图弹出框。弹出框总是从左上角显示。如何让它将箭头指向选定的单元格?代码如下:
-(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
JCCollectionData *favorite = [self.dataSource objectAtIndex:indexPath.row];
JCCollectionCellView *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
JCContactDetailViewController *contactDetail = [[JCContactDetailViewController alloc] init];
contactDetail.Contact = favorite;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:contactDetail];
nav.modalPresentationStyle = UIModalPresentationPopover;
nav.popoverPresentationController.delegate = self;
nav.popoverPresentationController.sourceView = cell;
nav.popoverPresentationController.sourceRect = [collectionView layoutAttributesForItemAtIndexPath:indexPath].frame;
nav.preferredContentSize = CGSizeMake(500, 400);
nav.popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
[self presentViewController:nav animated:YES completion:nil];
}
【问题讨论】:
标签: ios objective-c uicollectionview