我使用BWWalkthrough圖書館作爲我的個人演練。它很容易實現,但我有一個BWWalkthroughViewController的錯誤:我不會使用storyboard來創建這個主控制器,所以我已經通過代碼創建了我的自定義視圖,然後在BWWalkthroughViewController的viewDidLoad中設置了視圖和pageControl。其餘代碼與github存儲庫中的示例相同。使用BWWalkthrough Library,無故事板,演練定製
即BWWalkthroughViewController的viewDidLoad中:
override func viewDidLoad() {
super.viewDidLoad()
let welcomeview: WelcomeView = WelcomeView() // my custom view
view = welcomeview
self.pageControl = welcomeview.pageControl
...
}
和,因爲它的第一視圖,該RootViewController的被設置好的與BWWalkthroughViewController與viewDidLoad中修改。所以,我對於在AppDelegate.swift設置本演練一個FUNC:
func showWelcomeView() -> BWWalkthroughViewController{
let storyboard = UIStoryboard(name: "Welcome", bundle: nil)
let walkthrough: BWWalkthroughViewController = BWWalkthroughViewController()
let page_zero = storyboard.instantiateViewControllerWithIdentifier("walk_0") as! UIViewController
let page_one = storyboard.instantiateViewControllerWithIdentifier("walk_1") as! UIViewController
let page_two = storyboard.instantiateViewControllerWithIdentifier("walk_2") as! UIViewController
let page_three = storyboard.instantiateViewControllerWithIdentifier("walk_3") as! UIViewController
let page_four = storyboard.instantiateViewControllerWithIdentifier("walk_4") as! UIViewController
walkthrough.delegate = self
walkthrough.addViewController(page_zero)
walkthrough.addViewController(page_one)
walkthrough.addViewController(page_two)
walkthrough.addViewController(page_three)
walkthrough.addViewController(page_four)
return walkthrough
}
進出口使用這裏FUNC:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = showWelcomeView() // func usedhere
return true
}
沒有錯誤的應用程序運行。我可以看到我的自定義視圖和所有4個子視圖(walk_0 ... walk_4),我可以將它們滑動但沒有正確顯示:滾動條是免費的,不會停留在每個頁面上。
所以......我錯過了我的自定義視圖的一些步驟?請幫幫我!
這個位於2子視圖之間從我的IPhone截圖與滾動:
兄你能幫我看看我的問題https://stackoverflow.com/questions/45004255/how-to-add-label-in-bwwalkthrough-view-controller-with-swift-3? –