Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

uipageviewcontroller next button swift

//Very simple solution is here

//To change page (UIViewController) from a UIViewController, first get the instance of Parent ViewController (which will be UIPageViewController) and then set its current ViewController

//In my case I have a UIPageViewController named "UserDetailsPVC" and it contains 4 pages (UIViewControllers) which are as follows

  PageOneVC:UIViewController
  PageTwoVC:UIViewController
  PageThreeVC:UIViewController
  PageFourVC:UIViewController

//In the UIPageViewController lets define an array of pages

 var pages:[UIViewController] = [
        UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PageOneVC"),
        UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PageTwoVC"),
        UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PageThreeVC"),
        UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PageFourVC")
]

//Now to change page of UIPageViewController from any of the UIViewController

    // get parent view controller
    let parentVC = self.parent as! UserDetailsPVC

    // change page of PageViewController
    parentVC.setViewControllers([parentVC.pages[1]], direction: .forward, animated: true, completion: nil)
Comment

PREVIOUS NEXT
Code Example
Swift :: underline uitextfield swift rotate 
Swift :: fizzbuzz in swift 
Swift :: iOS 10.3.1 Simulator manually 
Swift :: swift programming language wikipedia 
Swift :: swift convert data to dictionary 
Swift :: Save structure in userdefaults ios swift 
Swift :: swift go back to previous view controller 
Swift :: swiftui text field 
Swift :: how do i get a string from a float swift to 1 decimal swift 
Swift :: using swipe gesture recognizer swift 
Swift :: get keyboard height swift 
Swift :: how to call app delegate function in swift 
Swift :: swift change background color 
Swift :: swift 5 check if dictionary contains key 
Swift :: dismiss keyboard when tap outside swift 5 
Swift :: hex color swiftui 
Swift :: change individual element alignment swiftui 
Swift :: load image from url in Image swiftui (iOS 15) 
Swift :: xcode how to know which textfield is selected 
Swift :: how to bold 1 word swift 
Swift :: reprobate 
Swift :: swift check if regex is in string 
Swift :: Swift "Hello, World!" Program 
Swift :: two variable sum in swift 
Swift :: Swift break with while Loop 
Swift :: Swift Print Variables and Literals 
Swift :: Access Array Elements Using Swift Range 
Swift :: map vs compactmap in swiftui 
Swift :: swift integer 
Swift :: swift methods 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =