[英]3D touch peek and pop hides navigation bar and status bar
嘗試
navigationController?.hidesBarsOnSwipe = false
navigationController?.hidesBarsOnTap = false
更新:
override func prefersStatusBarHidden() -> Bool {
return false
}
在我的情況下,因為我沒有設置正確的sourceRect
- (nullable UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext
viewControllerForLocation:(CGPoint)location
iOS使用整個視圖框架作為sourceRect
,它與導航欄和狀態欄重疊。
例如,如果你在tableView或collectionView中使用它,你應該寫這樣的東西:
NSIndexPath *indexPath = [self.collectionView indexPathForItemAtPoint:location];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPath];
// you need to check if indexPath or cell are nil
CGRect convertedRect = [cell convertRect:cell.bounds toView:self.collectionView];
previewingContext.sourceRect = convertedRect;
// and after that - return needed view controller
Swift版本:
guard let indexPath = collectionView.indexPathForItem(at: location),
let cell = collectionView.cellForItem(at: indexPath) else {
return nil
}
let convertedRect = cell.convert(cell.bounds, to: collectionView)
previewingContext.sourceRect = convertedRect
// and after that - return needed view controller
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.