我已实施滑动。它有五个子视图。它运作正常。
现在,根据具体情况,我需要直接转到第四个subViewController。在滑动之后不应该打扰用户应该能够在此跳跃之前向前和向后滑动 怎么办呢?
我使用这些代码行来实现滑动:
let vc0 = ViewController0(nibName: "ViewController0" ,bundle: nil)
self.addChildViewController(vc0)
self.myscrolview.addSubview(vc0.view)
vc0.didMoveToParentViewController(self)
let vc1 = ViewController1(nibName: "ViewController1",bundle: nil)
var frame1 = vc1.view.frame
frame1.origin.x = self.view.frame.size.width
vc1.view.frame=frame1
self.addChildViewController(vc1)
self.myscrolview.addSubview(vc1.view)
vc1.didMoveToParentViewController(self)
let vc2 = ViewController2(nibName: "ViewController2",bundle: nil)
var frame2 = vc2.view.frame
frame2.origin.x = self.view.frame.size.width * 2
vc2.view.frame=frame2
self.addChildViewController(vc2)
self.myscrolview.addSubview(vc2.view)
vc2.didMoveToParentViewController(self)
let vc3 = ViewController3(nibName: "ViewController3",bundle: nil)
var frame3 = vc3.view.frame
frame3.origin.x = self.view.frame.size.width * 3
vc3.view.frame=frame3
self.addChildViewController(vc3)
self.myscrolview.addSubview(vc3.view)
vc3.didMoveToParentViewController(self)
let vc4 = ViewController3(nibName: "ViewController4",bundle: nil)
var frame4 = vc4.view.frame
frame4.origin.x = self.view.frame.size.width * 4
vc4.view.frame=frame4
self.addChildViewController(vc4)
self.myscrolview.addSubview(vc4.view)
vc3.didMoveToParentViewController(self)
self.myscrolview.contentSize = CGSizeMake(self.view.frame.size.width * 5, self.view.frame.size.height-66)