ios - Adding am UIPageViewController in front of a UIViewController -
when app starts first time should display tutorial, screens semitransparent background, in front of first app screen.
i tried creating uipageviewcontroller object, adding view subview of current screen (self.view.addsubview(tutorialviewcontroller.view)
) , screen displayed, when swipe uipageviewcontroller
not responding event.
class tutorialviewcontroller:uipageviewcontroller, uipageviewcontrollerdatasource { var tutorialsviewcontrollers = [uiviewcontroller]() override func viewdidload() { super.viewdidload() tutorialsviewcontrollers.append(tutorial1viewcontroller()) tutorialsviewcontrollers.append(tutorial2viewcontroller()) tutorialsviewcontrollers.append(tutorial3viewcontroller()) tutorialsviewcontrollers.append(tutorial4viewcontroller()) tutorialsviewcontrollers.append(tutorial5viewcontroller()) self.setviewcontrollers([tutorialsviewcontrollers.first!], direction: .forward, animated: false) { (complete) -> void in } self.datasource = self } func pageviewcontroller(pageviewcontroller: uipageviewcontroller, viewcontrollerbeforeviewcontroller viewcontroller: uiviewcontroller) -> uiviewcontroller? { if let position = find(self.tutorialsviewcontrollers, viewcontroller) position > 0 { return self.tutorialsviewcontrollers[position - 1] } return nil } func pageviewcontroller(pageviewcontroller: uipageviewcontroller, viewcontrollerafterviewcontroller viewcontroller: uiviewcontroller) -> uiviewcontroller?{ if let position = find(self.tutorialsviewcontrollers, viewcontroller) position < self.tutorialsviewcontrollers.count - 1 { return self.tutorialsviewcontrollers[position - 1] } return nil } }
that's view controller code
let tutorialviewcontroller = tutorialviewcontroller() self.view.addsubview(tutorialviewcontroller.view)
did add tutorialviewcontroller
child view controller?
self.addchildviewcontroller(tutorialviewcontroller) self.view.addsubview(tutorialviewcontroller.view)
Comments
Post a Comment