Tap on pageControl to scroll to another view (tap on the dots)How do I check if a string contains another string in Objective-C?Passing Data between View ControllersiOS: UIScroll View - prevent scroll on view touchUIPageControl not visible when combined with UIScrollViewiOS/Obj-C UIScrollView views not being added properlyWhy don't use var at the beginning?adding a uipageviewcontroller to a uistackviewUIPageViewController ChildViewController disappears when UIActivityViewController is being used with Mail or SMSPageControl in Xcode UITestchange PageControl height from UIPageViewControllerDataSource

How to add the real hostname in the beginning of Linux cli command

Should I be on the paper from another PhD student that I constantly went on his meetings?

Beyond Futuristic Technology for an Alien Warship?

Why, even after his imprisonment, do people keep calling Hannibal Lecter "Doctor"?

Worlds with different mathematics and logic

My machine, client installed VPN,

Can the President of the US limit First Amendment rights?

Why isn't there armor to protect from spells in the Potterverse?

Which Catholic priests were given diplomatic missions?

Do I need to use BX wire in my house?

Why has Speaker Pelosi been so hesitant to impeach President Trump?

Why does it seem the best way to make a living is to invest in real estate?

Was the ruling that prorogation was unlawful only possible because of the creation of a separate supreme court?

Avoiding dust scattering when you drill

Earliest time frog can jump to the other side of a river in C#. Codility's task

Duck, duck, gone!

Is it mandatory to use contractions in tag questions and the like?

Would a horse be sufficient buffer to prevent injury when falling from a great height?

Why do Russians sometimes spell "жирный" (fatty) as "жырный"?

How many space launch vehicles are under development worldwide?

Can I pay some of the cost of an activated ability lots of times to get more out of the effect?

Windows 10 deletes lots of tiny files super slowly. Anything that can be done to speed it up?

Is it possible to take a database offline when doing a backup using an SQL job?

Would allowing versatile weapons wielded in two hands to benefit from Dueling be unbalanced?



Tap on pageControl to scroll to another view (tap on the dots)


How do I check if a string contains another string in Objective-C?Passing Data between View ControllersiOS: UIScroll View - prevent scroll on view touchUIPageControl not visible when combined with UIScrollViewiOS/Obj-C UIScrollView views not being added properlyWhy don't use var at the beginning?adding a uipageviewcontroller to a uistackviewUIPageViewController ChildViewController disappears when UIActivityViewController is being used with Mail or SMSPageControl in Xcode UITestchange PageControl height from UIPageViewControllerDataSource






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have set up PageViewControll with 2 views.
I am able to move between the views and the pageControl (Dots) correspond to the correct page- however tapping the dots doesn't scroll to the correct view just yet.



I found few answers on here on how to create the function but was not able to implement is successfully to make it work.
The code for the page controller is below (without the tap function)
The full code is :



func configurePageControl() 
pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 50,width: UIScreen.main.bounds.width,height: 50))
self.pageControl.numberOfPages = viewControllerList.count
self.pageControl.currentPage = 0
self.pageControl.alpha = 0.5
self.pageControl.tintColor = UIColor.white
self.pageControl.pageIndicatorTintColor = UIColor.black
self.pageControl.currentPageIndicatorTintColor = UIColor.white
self.view.addSubview(pageControl)




@IBAction func pageControltapped(_ sender: Any)
guard let pageControl = sender as? UIPageControl else return
let selectedPage = pageControl.currentPage
self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



}


thanks for any help!!










share|improve this question
































    2















    I have set up PageViewControll with 2 views.
    I am able to move between the views and the pageControl (Dots) correspond to the correct page- however tapping the dots doesn't scroll to the correct view just yet.



    I found few answers on here on how to create the function but was not able to implement is successfully to make it work.
    The code for the page controller is below (without the tap function)
    The full code is :



    func configurePageControl() 
    pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 50,width: UIScreen.main.bounds.width,height: 50))
    self.pageControl.numberOfPages = viewControllerList.count
    self.pageControl.currentPage = 0
    self.pageControl.alpha = 0.5
    self.pageControl.tintColor = UIColor.white
    self.pageControl.pageIndicatorTintColor = UIColor.black
    self.pageControl.currentPageIndicatorTintColor = UIColor.white
    self.view.addSubview(pageControl)




    @IBAction func pageControltapped(_ sender: Any)
    guard let pageControl = sender as? UIPageControl else return
    let selectedPage = pageControl.currentPage
    self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



    }


    thanks for any help!!










    share|improve this question




























      2












      2








      2








      I have set up PageViewControll with 2 views.
      I am able to move between the views and the pageControl (Dots) correspond to the correct page- however tapping the dots doesn't scroll to the correct view just yet.



      I found few answers on here on how to create the function but was not able to implement is successfully to make it work.
      The code for the page controller is below (without the tap function)
      The full code is :



      func configurePageControl() 
      pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 50,width: UIScreen.main.bounds.width,height: 50))
      self.pageControl.numberOfPages = viewControllerList.count
      self.pageControl.currentPage = 0
      self.pageControl.alpha = 0.5
      self.pageControl.tintColor = UIColor.white
      self.pageControl.pageIndicatorTintColor = UIColor.black
      self.pageControl.currentPageIndicatorTintColor = UIColor.white
      self.view.addSubview(pageControl)




      @IBAction func pageControltapped(_ sender: Any)
      guard let pageControl = sender as? UIPageControl else return
      let selectedPage = pageControl.currentPage
      self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



      }


      thanks for any help!!










      share|improve this question
















      I have set up PageViewControll with 2 views.
      I am able to move between the views and the pageControl (Dots) correspond to the correct page- however tapping the dots doesn't scroll to the correct view just yet.



      I found few answers on here on how to create the function but was not able to implement is successfully to make it work.
      The code for the page controller is below (without the tap function)
      The full code is :



      func configurePageControl() 
      pageControl = UIPageControl(frame: CGRect(x: 0,y: UIScreen.main.bounds.maxY - 50,width: UIScreen.main.bounds.width,height: 50))
      self.pageControl.numberOfPages = viewControllerList.count
      self.pageControl.currentPage = 0
      self.pageControl.alpha = 0.5
      self.pageControl.tintColor = UIColor.white
      self.pageControl.pageIndicatorTintColor = UIColor.black
      self.pageControl.currentPageIndicatorTintColor = UIColor.white
      self.view.addSubview(pageControl)




      @IBAction func pageControltapped(_ sender: Any)
      guard let pageControl = sender as? UIPageControl else return
      let selectedPage = pageControl.currentPage
      self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



      }


      thanks for any help!!







      ios swift swift4 uipageviewcontroller






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 30 at 1:19







      roypnyc

















      asked Mar 28 at 19:44









      roypnycroypnyc

      136 bronze badges




      136 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          1. You need to create IBAction for pageControl from which you can detect which dot was tapped.



          2. Then, you need to use setViewControllers(_:direction:animated:completion:) method to scroll page programmatically.



            func setViewControllers(_ viewControllers: [UIViewController]?, 
            direction: UIPageViewController.NavigationDirection,
            animated: Bool,
            completion: ((Bool) -> Void)? = nil)


            Here's the link to documentation



          Use following code:



          @IBAction func pageControltapped(_ sender: Any) 
          guard let pageControl = sender as? UIPageControl else return
          let selectedPage = pageControl.currentPage
          self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



          Add target for pageControl to link it with IBAction:



          func configurePageControl() 
          //...your code as it is....
          //add following line
          self.pageControl.addTarget(self, action: #selector(pageControltapped(_:)), for: .touchUpInside)






          share|improve this answer



























          • Thank you so much- I have been trying to resolve an error- "Cannot convert value of type 'UIViewController' to expected argument type '[UIViewController]?'", in the IBAaction.- any idea?

            – roypnyc
            Mar 28 at 22:22












          • It is my mistake! setViewControllers() method expects array for viewControllers parameter. You can simply solve it by replacing viewControllerList[selectedPage] with `[viewControllerList[selectedPage]]. I've also updated my code for you.

            – Bhaumik
            Mar 28 at 22:45












          • -Errors are gone but it is still not working unfortunately... I am not sure what I am leaving out- I will add the full code above maybe that will help in solving it

            – roypnyc
            Mar 29 at 0:39












          • It is because you need to link pageControltapped() method with pageControl. Check my updated answer.

            – Bhaumik
            Mar 29 at 15:14






          • 1





            I approved it and thank you so much! i really appreciate your patience and help with this!! I don't have enough reputations for the upvote to show haha :) but its recording them.

            – roypnyc
            Mar 29 at 20:12














          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405731%2ftap-on-pagecontrol-to-scroll-to-another-view-tap-on-the-dots%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0
















          1. You need to create IBAction for pageControl from which you can detect which dot was tapped.



          2. Then, you need to use setViewControllers(_:direction:animated:completion:) method to scroll page programmatically.



            func setViewControllers(_ viewControllers: [UIViewController]?, 
            direction: UIPageViewController.NavigationDirection,
            animated: Bool,
            completion: ((Bool) -> Void)? = nil)


            Here's the link to documentation



          Use following code:



          @IBAction func pageControltapped(_ sender: Any) 
          guard let pageControl = sender as? UIPageControl else return
          let selectedPage = pageControl.currentPage
          self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



          Add target for pageControl to link it with IBAction:



          func configurePageControl() 
          //...your code as it is....
          //add following line
          self.pageControl.addTarget(self, action: #selector(pageControltapped(_:)), for: .touchUpInside)






          share|improve this answer



























          • Thank you so much- I have been trying to resolve an error- "Cannot convert value of type 'UIViewController' to expected argument type '[UIViewController]?'", in the IBAaction.- any idea?

            – roypnyc
            Mar 28 at 22:22












          • It is my mistake! setViewControllers() method expects array for viewControllers parameter. You can simply solve it by replacing viewControllerList[selectedPage] with `[viewControllerList[selectedPage]]. I've also updated my code for you.

            – Bhaumik
            Mar 28 at 22:45












          • -Errors are gone but it is still not working unfortunately... I am not sure what I am leaving out- I will add the full code above maybe that will help in solving it

            – roypnyc
            Mar 29 at 0:39












          • It is because you need to link pageControltapped() method with pageControl. Check my updated answer.

            – Bhaumik
            Mar 29 at 15:14






          • 1





            I approved it and thank you so much! i really appreciate your patience and help with this!! I don't have enough reputations for the upvote to show haha :) but its recording them.

            – roypnyc
            Mar 29 at 20:12
















          0
















          1. You need to create IBAction for pageControl from which you can detect which dot was tapped.



          2. Then, you need to use setViewControllers(_:direction:animated:completion:) method to scroll page programmatically.



            func setViewControllers(_ viewControllers: [UIViewController]?, 
            direction: UIPageViewController.NavigationDirection,
            animated: Bool,
            completion: ((Bool) -> Void)? = nil)


            Here's the link to documentation



          Use following code:



          @IBAction func pageControltapped(_ sender: Any) 
          guard let pageControl = sender as? UIPageControl else return
          let selectedPage = pageControl.currentPage
          self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



          Add target for pageControl to link it with IBAction:



          func configurePageControl() 
          //...your code as it is....
          //add following line
          self.pageControl.addTarget(self, action: #selector(pageControltapped(_:)), for: .touchUpInside)






          share|improve this answer



























          • Thank you so much- I have been trying to resolve an error- "Cannot convert value of type 'UIViewController' to expected argument type '[UIViewController]?'", in the IBAaction.- any idea?

            – roypnyc
            Mar 28 at 22:22












          • It is my mistake! setViewControllers() method expects array for viewControllers parameter. You can simply solve it by replacing viewControllerList[selectedPage] with `[viewControllerList[selectedPage]]. I've also updated my code for you.

            – Bhaumik
            Mar 28 at 22:45












          • -Errors are gone but it is still not working unfortunately... I am not sure what I am leaving out- I will add the full code above maybe that will help in solving it

            – roypnyc
            Mar 29 at 0:39












          • It is because you need to link pageControltapped() method with pageControl. Check my updated answer.

            – Bhaumik
            Mar 29 at 15:14






          • 1





            I approved it and thank you so much! i really appreciate your patience and help with this!! I don't have enough reputations for the upvote to show haha :) but its recording them.

            – roypnyc
            Mar 29 at 20:12














          0














          0










          0









          1. You need to create IBAction for pageControl from which you can detect which dot was tapped.



          2. Then, you need to use setViewControllers(_:direction:animated:completion:) method to scroll page programmatically.



            func setViewControllers(_ viewControllers: [UIViewController]?, 
            direction: UIPageViewController.NavigationDirection,
            animated: Bool,
            completion: ((Bool) -> Void)? = nil)


            Here's the link to documentation



          Use following code:



          @IBAction func pageControltapped(_ sender: Any) 
          guard let pageControl = sender as? UIPageControl else return
          let selectedPage = pageControl.currentPage
          self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



          Add target for pageControl to link it with IBAction:



          func configurePageControl() 
          //...your code as it is....
          //add following line
          self.pageControl.addTarget(self, action: #selector(pageControltapped(_:)), for: .touchUpInside)






          share|improve this answer















          1. You need to create IBAction for pageControl from which you can detect which dot was tapped.



          2. Then, you need to use setViewControllers(_:direction:animated:completion:) method to scroll page programmatically.



            func setViewControllers(_ viewControllers: [UIViewController]?, 
            direction: UIPageViewController.NavigationDirection,
            animated: Bool,
            completion: ((Bool) -> Void)? = nil)


            Here's the link to documentation



          Use following code:



          @IBAction func pageControltapped(_ sender: Any) 
          guard let pageControl = sender as? UIPageControl else return
          let selectedPage = pageControl.currentPage
          self.setViewControllers([viewControllerList[selectedPage]], direction: .forward, animated: true, completion: nil)



          Add target for pageControl to link it with IBAction:



          func configurePageControl() 
          //...your code as it is....
          //add following line
          self.pageControl.addTarget(self, action: #selector(pageControltapped(_:)), for: .touchUpInside)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 29 at 15:13

























          answered Mar 28 at 20:20









          BhaumikBhaumik

          9131 gold badge6 silver badges17 bronze badges




          9131 gold badge6 silver badges17 bronze badges















          • Thank you so much- I have been trying to resolve an error- "Cannot convert value of type 'UIViewController' to expected argument type '[UIViewController]?'", in the IBAaction.- any idea?

            – roypnyc
            Mar 28 at 22:22












          • It is my mistake! setViewControllers() method expects array for viewControllers parameter. You can simply solve it by replacing viewControllerList[selectedPage] with `[viewControllerList[selectedPage]]. I've also updated my code for you.

            – Bhaumik
            Mar 28 at 22:45












          • -Errors are gone but it is still not working unfortunately... I am not sure what I am leaving out- I will add the full code above maybe that will help in solving it

            – roypnyc
            Mar 29 at 0:39












          • It is because you need to link pageControltapped() method with pageControl. Check my updated answer.

            – Bhaumik
            Mar 29 at 15:14






          • 1





            I approved it and thank you so much! i really appreciate your patience and help with this!! I don't have enough reputations for the upvote to show haha :) but its recording them.

            – roypnyc
            Mar 29 at 20:12


















          • Thank you so much- I have been trying to resolve an error- "Cannot convert value of type 'UIViewController' to expected argument type '[UIViewController]?'", in the IBAaction.- any idea?

            – roypnyc
            Mar 28 at 22:22












          • It is my mistake! setViewControllers() method expects array for viewControllers parameter. You can simply solve it by replacing viewControllerList[selectedPage] with `[viewControllerList[selectedPage]]. I've also updated my code for you.

            – Bhaumik
            Mar 28 at 22:45












          • -Errors are gone but it is still not working unfortunately... I am not sure what I am leaving out- I will add the full code above maybe that will help in solving it

            – roypnyc
            Mar 29 at 0:39












          • It is because you need to link pageControltapped() method with pageControl. Check my updated answer.

            – Bhaumik
            Mar 29 at 15:14






          • 1





            I approved it and thank you so much! i really appreciate your patience and help with this!! I don't have enough reputations for the upvote to show haha :) but its recording them.

            – roypnyc
            Mar 29 at 20:12

















          Thank you so much- I have been trying to resolve an error- "Cannot convert value of type 'UIViewController' to expected argument type '[UIViewController]?'", in the IBAaction.- any idea?

          – roypnyc
          Mar 28 at 22:22






          Thank you so much- I have been trying to resolve an error- "Cannot convert value of type 'UIViewController' to expected argument type '[UIViewController]?'", in the IBAaction.- any idea?

          – roypnyc
          Mar 28 at 22:22














          It is my mistake! setViewControllers() method expects array for viewControllers parameter. You can simply solve it by replacing viewControllerList[selectedPage] with `[viewControllerList[selectedPage]]. I've also updated my code for you.

          – Bhaumik
          Mar 28 at 22:45






          It is my mistake! setViewControllers() method expects array for viewControllers parameter. You can simply solve it by replacing viewControllerList[selectedPage] with `[viewControllerList[selectedPage]]. I've also updated my code for you.

          – Bhaumik
          Mar 28 at 22:45














          -Errors are gone but it is still not working unfortunately... I am not sure what I am leaving out- I will add the full code above maybe that will help in solving it

          – roypnyc
          Mar 29 at 0:39






          -Errors are gone but it is still not working unfortunately... I am not sure what I am leaving out- I will add the full code above maybe that will help in solving it

          – roypnyc
          Mar 29 at 0:39














          It is because you need to link pageControltapped() method with pageControl. Check my updated answer.

          – Bhaumik
          Mar 29 at 15:14





          It is because you need to link pageControltapped() method with pageControl. Check my updated answer.

          – Bhaumik
          Mar 29 at 15:14




          1




          1





          I approved it and thank you so much! i really appreciate your patience and help with this!! I don't have enough reputations for the upvote to show haha :) but its recording them.

          – roypnyc
          Mar 29 at 20:12






          I approved it and thank you so much! i really appreciate your patience and help with this!! I don't have enough reputations for the upvote to show haha :) but its recording them.

          – roypnyc
          Mar 29 at 20:12





















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405731%2ftap-on-pagecontrol-to-scroll-to-another-view-tap-on-the-dots%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript