我有5页的UIPageViewController。它是在每个页面上登录动画UIViewControllers动画。我研究了几天,无法找到停止动画的方法,并在滚动(页面更改)发生后重置页面。
我的UIPageViewController设置如下:
class BoardingPageViewController: UIPageViewController {
override func viewDidLoad() {
super.viewDidLoad()
dataSource = self
delegate = self
setViewControllers([getStepOne()], direction: .forward, animated: false, completion: nil)
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
func getStepOne() -> BoardView1ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView1") as! BoardView1ViewController
}
func getStepTwo() -> BoardView2ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView2") as! BoardView2ViewController
}
func getStepThree() -> BoardView3ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView3") as! BoardView3ViewController
}
func getStepFour() -> BoardView4ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView4") as! BoardView4ViewController
}
func getStepFive() -> BoardView5ViewController {
return storyboard!.instantiateViewController(withIdentifier: "BoardView5") as! BoardView5ViewController
}
}
extension BoardingPageViewController : UIPageViewControllerDataSource {
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if viewController.isKind(of: BoardView5ViewController.self) {
// 5 -> 4
return getStepFour()
} else if viewController.isKind(of: BoardView4ViewController.self) {
// 4 -> 3
return getStepThree()
} else if viewController.isKind(of: BoardView3ViewController.self) {
// 3 -> 2
return getStepTwo()
} else if viewController.isKind(of: BoardView2ViewController.self) {
// 2 -> 1
return getStepOne()
} else {
// 0 -> end of the road
return nil
}
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if viewController.isKind(of: BoardView1ViewController.self) {
// 0 -> 1
return getStepTwo()
} else if viewController.isKind(of: BoardView2ViewController.self) {
// 1 -> 2
return getStepThree()
} else if viewController.isKind(of: BoardView3ViewController.self) {
// 1 -> 2
return getStepFour()
} else if viewController.isKind(of: BoardView4ViewController.self) {
// 1 -> 2
return getStepFive()
} else {
// 2 -> end of the road
return nil
}
}
func presentationCount(for pageViewController: UIPageViewController) -> Int {
return 5
}
func presentationIndex(for pageViewController: UIPageViewController) -> Int {
return 0
}
}
extension BoardingPageViewController : UIPageViewControllerDelegate {
}
我的UIViewControllers与简单的动画都很相似。我试图通过将chainAni值切换为false并在ViewDidDisappear上调用它来实现这一点。但如果在动画中间发生页面切换,它就不起作用。
override func viewDidAppear(_ animated: Bool) {
chainAni = true
ani0()
}
func ani0() {
if chainAni != true {
return
}
UIView.animate(withDuration: 1, delay: 1, animations: {
self.handPic.alpha = 1
}) { (false) in
self.ani1()
}
}
func ani1() {
if chainAni != true {
return
}
UIView.animate(withDuration: 1.5, delay: 1, usingSpringWithDamping: 0.5, initialSpringVelocity: 0, options: [], animations: {
self.highlightAction(any: self.handPic)
self.highlightAction(any: self.folderBtn)
}) { (false) in
self.ani2()
}
}
func ani2() {
if chainAni != true {
return
}
UIView.animate(withDuration: 1.5, delay: 1, animations: {
self.unhighlightAction(any: self.handPic)
self.unhighlightAction(any: self.folderBtn)
}) { (false) in
self.ani3()
}
}
func ani3() {
if chainAni != true {
return
}
UIView.animate(withDuration: 0.5, delay: 0, animations: {
self.handPic.alpha = 0
self.alertImg.alpha = 1
self.alertImg.transform = .identity
}) { (false) in
self.ani4()
}
}
func clearAni() {
alertImg.image = #imageLiteral(resourceName: "alert1")
darkView.removeFromSuperview()
screenView.removeFromSuperview()
mainImg.alpha = 1
alertImg.alpha = 0
alert2Img.alpha = 0
handPic.alpha = 0
handPic.transform = .identity
hand2Pic.alpha = 0
hand2Pic.transform = .identity
newFolderImg.alpha = 0
newFolderImg.transform = .identity
}
override func viewDidDisappear(_ animated: Bool) {
clearAni()
chainAni = false
}
答案 0 :(得分:0)
所以,我想我必须从它的超视图层中删除每个动画。
SELECT
SUBSTRING(Value, 0, CHARINDEX('|', Value)) AS column1,
SUBSTRING(Value, CHARINDEX('|', Value) + 1,
CHARINDEX('/', Value) - CHARINDEX('|', Value) - 1) AS column2,
SUBSTRING(Value, CHARINDEX('/', Value) + 1, LEN(Value) - CHARINDEX('/', Value)) AS column3