目前我有一个UIPageController,它似乎在刷卡时跳过屏幕。这很奇怪,因为我在使用VC时将打印行语句放入其中,并且在快速转到同一滑动中的下一个VC之前,它看起来像是移动到正确的VC。 (即转到第2步,然后转到第3步,但在相同的滑动过程中)以下是它的设置方式:
var maxPages : Int!
var currentIndex : Int = 0
var listOfViews = ["step1", "step2", "step3", "step4"]
//maxPages = listOfViews.count in viewDidLoad
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
var index : Int = (viewController.view as? BGMWelcomePageView)!.index
index += 1
if (index == maxPages)
{
index = 0
}
return self.getViewControllerWithImage(index)
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
var index : Int = (viewController.view as? BGMWelcomePageView)!.index
index -= 1
if (index < 0)
{
index = maxPages - 1
}
//This is the function called to get the corresponding view controller
func getViewControllerWithImage(_ index: Int) -> UIViewController
{
var vc : UIViewController
let loopCount = 999//(index < self.maxPages - 1) ? 1 : 99
switch listOfViews[index] {
case "step1":
vc = self.buildViewControllerWithImage(titleString: "FIRST_SCREEN_TITLE".localized, descriptionString: "FIRST_SCREEN_DESCRIPTION".localized, backgroundImage: "fractal_blue", jsonFile: "Welcome_Step_01_V01", index: index, loopCount: loopCount)
print("XXXX Current listView: step1 XXXX")
case "step2":
vc = self.buildViewControllerWithImage(titleString: "SECOND_SCREEN_TITLE".localized, descriptionString: "SECOND_SCREEN_DESCRIPTION".localized, backgroundImage: "fractal_blue", jsonFile:
"Welcome_Step_02_V01", index: index, loopCount: loopCount)
print("XXXX Current listView: step2 XXXXX")
case "step3":
vc = self.buildViewControllerWithImage(titleString: "THIRD_SCREEN_TITLE".localized, descriptionString: "THIRD_SCREEN_DESCRIPTION".localized, backgroundImage: "fractal_blue", jsonFile: "Welcome_Step_03_V01", index: index, loopCount: loopCount)
print("XXXXX Current listView: step3 XXXXXX")
case "step4":
vc = self.buildViewControllerWithImage(titleString: "FOURTH_SCREEN_TITLE".localized, descriptionString: "FOURTH_SCREEN_DESCRIPTION".localized, backgroundImage: "fractal_blue", jsonFile: "Welcome_Step_04_V01", index: index, loopCount: loopCount)
print("XXXXXX Current listView: step4 XXXXXX")
default:
vc = self.buildViewControllerWithImage(titleString: "FIRST_SCREEN_TITLE".localized, descriptionString: "", backgroundImage: "fractal_blue", jsonFile: "Welcome_Step_01_V01", index: index, loopCount: loopCount)
print("XXXXX Current listView: default XXXXXX")
}
self.currentIndex = index
//print("XXXXX Current Index: \(self.currentIndex) XXXXXXX")
return vc
}