iMessage Photo Browser在点击效果上隐藏导航栏

时间:2014-10-17 03:01:01

标签: ios objective-c uicollectionview uinavigationbar imessage

当我点击聊天帖子中的照片时,我正在尝试创建iMessage中存在的“照片浏览器”的副本。我坚持他们如何让导航栏的行为在点击时正确消失。

目前我致电

    [self.navigationController setNavigationBarHidden:YES animated:YES];

点击视图隐藏导航栏时。然而,由于视图如何响应顶部布局指南,这会导致视图向上移动。 iMessage有它所以视图完全忽略了顶部布局指南,只是坐在它下面。我怎么能得到同样的行为?

以下是我创建照片集合视图的代码:

UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    [layout setSectionInset:UIEdgeInsetsZero];
    [layout setMinimumInteritemSpacing:0.0];
    [layout setMinimumLineSpacing:0.0];
    [layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];

    _collectionView = [[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layout];
    [_collectionView setBackgroundColor:[UIColor whiteColor]];
    [_collectionView setPagingEnabled:YES];
    [_collectionView setAlwaysBounceHorizontal:YES];
    [_collectionView setDataSource:self];
    [_collectionView setDelegate:self];
    [_collectionView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
    [self.view addSubview:_collectionView];

.........

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(collectionView.bounds.size.width  - collectionViewLayout.sectionInset.left - collectionViewLayout.sectionInset.right, collectionView.bounds.size.height - collectionViewLayout.sectionInset.bottom - collectionViewLayout.sectionInset.top);
}

0 个答案:

没有答案