2017-08-10 22 views
0

collectionViewCell的內部我想創建一個視圖,底部有點,可以在視圖之間滑動。我應該使用UIPageController來手動顯示點並實現手勢識別,還是可以在collectionViewCell內使用UIPageViewController在collectionViewCell中使用UIPageViewController

+0

使用集合視圖細胞的容器視圖 –

回答

1

是的,你可以把它放在你的牢房裏。它不一定是全屏。實際上它可以用作任何其他的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]; 
1

迅速

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) 
+0

感謝您編輯我的片段中迅速!我的代碼在目標c中被剪切,並且不在我的筆記本電腦附近(對於xcode)將其轉換爲swift!如果您不介意我會將此代碼添加到我的答案中。再次感謝! :) –

+0

@MohammadBashirSidani你可以upvote爲我的迅捷解決方案,以便其他可以得到它在使用.. Hapy編碼:) –

+0

當然!我會 –

相關問題