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;
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
add a comment
|
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
add a comment
|
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
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
ios swift swift4 uipageviewcontroller
edited Mar 30 at 1:19
roypnyc
asked Mar 28 at 19:44
roypnycroypnyc
136 bronze badges
136 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
You need to create IBAction for
pageControl
from which you can detect which dot was tapped.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)
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 replacingviewControllerList[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 linkpageControltapped()
method withpageControl
. 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
|
show 1 more comment
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You need to create IBAction for
pageControl
from which you can detect which dot was tapped.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)
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 replacingviewControllerList[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 linkpageControltapped()
method withpageControl
. 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
|
show 1 more comment
You need to create IBAction for
pageControl
from which you can detect which dot was tapped.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)
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 replacingviewControllerList[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 linkpageControltapped()
method withpageControl
. 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
|
show 1 more comment
You need to create IBAction for
pageControl
from which you can detect which dot was tapped.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)
You need to create IBAction for
pageControl
from which you can detect which dot was tapped.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)
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 replacingviewControllerList[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 linkpageControltapped()
method withpageControl
. 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
|
show 1 more comment
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 replacingviewControllerList[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 linkpageControltapped()
method withpageControl
. 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
|
show 1 more comment
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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