我试图用3个屏幕实现教程,在最后一页,当用户滑动时,应用程序应该转到主UIViewController。当pageViewController数据源设置为self时,不会识别滑动手势。有解决方法吗?
public void Test()
{
_mainform.DoSmth("test");
}
以下是我希望通过滑动手势调用的功能。当pageViewController数据源设置为nil
时,这种方法有效class TourViewController: UIViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
var pageViewController: UIPageViewController!
var pageTitles: NSArray!
var pageImages: NSArray!
var pageDesc: NSArray!
override func viewDidLoad() {
super.viewDidLoad()
self.pageTitles = NSArray(objects: "page 1", "page 2", "page 3")
self.pageImages = NSArray(objects: "image 1", "image 2", "image 3")
self.pageDesc = NSArray(objects: "note 1", "note 2", "note 3")
self.pageViewController = self.storyboard?.instantiateViewControllerWithIdentifier("PageViewController") as! UIPageViewController
self.pageViewController.dataSource = self
var startVC = self.viewControllerAtIndex(0) as ContentViewController
var viewControllers = NSArray(object: startVC)
self.pageViewController.setViewControllers(viewControllers as! [UIViewController], direction: .Forward, animated: true, completion: nil)
self.pageViewController.view.frame = CGRectMake(0, 30, self.view.frame.width, self.view.frame.size.height-60)
self.addChildViewController(self.pageViewController)
self.view.addSubview(self.pageViewController.view)
self.pageViewController.didMoveToParentViewController(self)
self.pageViewController.delegate = self
}
我可以在以下功能中做些什么吗?
func handleSwipes(sender:UISwipeGestureRecognizer) {
if (sender.direction == .Left) {
print("Swipe Left")
}
if (sender.direction == .Right) {
print("Swipe Right")
}
}
找不到任何关于此的快速示例。请帮忙。感谢。