在collectionViewCell
的內部我想創建一個視圖,底部有點,可以在視圖之間滑動。我應該使用UIPageController
來手動顯示點並實現手勢識別,還是可以在collectionViewCell
內使用UIPageViewController
?在collectionViewCell中使用UIPageViewController
回答
是的,你可以把它放在你的牢房裏。它不一定是全屏。實際上它可以用作任何其他的UIViewController。如果你想將它嵌入到一個更小的矩形中,你可以使用UIViewController遏制。
假設您想要將其嵌入到父控制器,它是一個UIViewController子類。然後定義一個pageViewController屬性,並將其添加爲viewDidLoad中子視圖控制器:
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageViewController.view.frame = ... //set the frame or add autolayout constraints
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
在迅速:
let pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
pageViewController.view.frame = view.frame//set frame
self.addChildViewController(pageViewController)
view.addSubview(pageViewController.view)
pageViewController.didMove(toParentViewController: self)
感謝您編輯我的片段中迅速!我的代碼在目標c中被剪切,並且不在我的筆記本電腦附近(對於xcode)將其轉換爲swift!如果您不介意我會將此代碼添加到我的答案中。再次感謝! :) –
@MohammadBashirSidani你可以upvote爲我的迅捷解決方案,以便其他可以得到它在使用.. Hapy編碼:) –
當然!我會 –
- 1. 在UIPageViewController中使用UISlider
- 2. 在UIView中使用UIPageViewController
- 3. PageControl在UIPageViewController中使用backgroundColor
- 4. 使用collectionViewCell和tableViewCell
- 5. 在ViewController的CollectionViewCell中使用PageControl
- 6. 如何在故事板中使用UIPageViewController?
- 7. 在故事板中使用UIPageViewController
- 8. 嵌套在CollectionViewCell中的TableView
- 9. 如何使用UIPageViewController
- 10. Custom CollectionViewCell
- 11. 在UIPageViewController
- 12. 在UIPageViewController
- 13. UIPageViewController * pageViewController =(UIPageViewController *)self.window.rootViewController;
- 14. UIPageViewController一個UIPageViewController
- 15. 使用PINRemoteImage填充CollectionViewCell圖像
- 16. 我可以在1個UICollectionView中使用collectionViewCell 2 Cell嗎?
- 17. Swift - 如何在UITableViewCell中使用CollectionViewCell打開另一個viewcontroller
- 18. 與UIPageViewController一起使用NIBs
- 19. 在UIPageViewController中禁用/啓用滾動
- 20. 標籤從CollectionViewCell中消失
- 21. 單擊CollectionViewCell中的按鈕
- 22. CollectionViewCell中的UIButton「IndexPath不起作用」
- 23. 在CollectionViewCell中輸入UITextField(swift 3 xcode)
- 24. 在TableViewCell中重新加載CollectionviewCell
- 25. 在UIView中調整CollectionViewCell的大小
- 26. UIPageViewController中的Pagenumber
- 27. UITableViewCell中的UIPageViewController
- 28. UIPageViewController中的UISegmentControl
- 29. 的TableView在UIPageViewController
- 30. ViewControllers在UIPageViewController
使用集合視圖細胞的容器視圖 –