func UIPageViewController didFinishAnimating not working
This function is never printing:
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
why?
entire code:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource
{
var AdsContent: AdsController? = nil
static var adsPageController:AdsPageController?
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
AdsPageController.adsPageController = self
}
override func viewWillAppear(_ animated: Bool) {
self.setViewControllers([getViewControllerAtIndex(pageIndex: MyUtils.loadAdIndex())] as [UIViewController], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)
}
// MARK: UIPageViewControllerDataSource Methods
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 0) || (index == NSNotFound))
{
index = 10
}
index-=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 9) || index == NSNotFound)
{
index = -1
}
index+=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
func getViewControllerAtIndex(pageIndex: NSInteger) -> AdsController{
let AdsContent: AdsController? = self.storyboard?.instantiateViewController(withIdentifier: "AdViewP") as? AdsController
AdsContent?.pageIndex = pageIndex
return AdsContent!
}
}
I want to know when a page transition has completed, I've implemented the didFinishAnimating method from UIPageViewController, but it's seems not working properly.
ios swift swift3 uipageviewcontroller
add a comment |
This function is never printing:
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
why?
entire code:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource
{
var AdsContent: AdsController? = nil
static var adsPageController:AdsPageController?
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
AdsPageController.adsPageController = self
}
override func viewWillAppear(_ animated: Bool) {
self.setViewControllers([getViewControllerAtIndex(pageIndex: MyUtils.loadAdIndex())] as [UIViewController], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)
}
// MARK: UIPageViewControllerDataSource Methods
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 0) || (index == NSNotFound))
{
index = 10
}
index-=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 9) || index == NSNotFound)
{
index = -1
}
index+=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
func getViewControllerAtIndex(pageIndex: NSInteger) -> AdsController{
let AdsContent: AdsController? = self.storyboard?.instantiateViewController(withIdentifier: "AdViewP") as? AdsController
AdsContent?.pageIndex = pageIndex
return AdsContent!
}
}
I want to know when a page transition has completed, I've implemented the didFinishAnimating method from UIPageViewController, but it's seems not working properly.
ios swift swift3 uipageviewcontroller
add a comment |
This function is never printing:
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
why?
entire code:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource
{
var AdsContent: AdsController? = nil
static var adsPageController:AdsPageController?
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
AdsPageController.adsPageController = self
}
override func viewWillAppear(_ animated: Bool) {
self.setViewControllers([getViewControllerAtIndex(pageIndex: MyUtils.loadAdIndex())] as [UIViewController], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)
}
// MARK: UIPageViewControllerDataSource Methods
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 0) || (index == NSNotFound))
{
index = 10
}
index-=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 9) || index == NSNotFound)
{
index = -1
}
index+=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
func getViewControllerAtIndex(pageIndex: NSInteger) -> AdsController{
let AdsContent: AdsController? = self.storyboard?.instantiateViewController(withIdentifier: "AdViewP") as? AdsController
AdsContent?.pageIndex = pageIndex
return AdsContent!
}
}
I want to know when a page transition has completed, I've implemented the didFinishAnimating method from UIPageViewController, but it's seems not working properly.
ios swift swift3 uipageviewcontroller
This function is never printing:
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
why?
entire code:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource
{
var AdsContent: AdsController? = nil
static var adsPageController:AdsPageController?
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
AdsPageController.adsPageController = self
}
override func viewWillAppear(_ animated: Bool) {
self.setViewControllers([getViewControllerAtIndex(pageIndex: MyUtils.loadAdIndex())] as [UIViewController], direction: UIPageViewControllerNavigationDirection.forward, animated: true, completion: nil)
}
// MARK: UIPageViewControllerDataSource Methods
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 0) || (index == NSNotFound))
{
index = 10
}
index-=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController?
{
self.AdsContent = viewController as? AdsController
var index = AdsContent!.pageIndex
if ((index == 9) || index == NSNotFound)
{
index = -1
}
index+=1
return getViewControllerAtIndex(pageIndex: index)
}
func pageViewController(_ pageViewController: UIPageViewController,
didFinishAnimating finished: Bool,
previousViewControllers: [UIViewController],
transitionCompleted completed: Bool){
if completed||finished{
print("completed or finished")
}
}
func getViewControllerAtIndex(pageIndex: NSInteger) -> AdsController{
let AdsContent: AdsController? = self.storyboard?.instantiateViewController(withIdentifier: "AdViewP") as? AdsController
AdsContent?.pageIndex = pageIndex
return AdsContent!
}
}
I want to know when a page transition has completed, I've implemented the didFinishAnimating method from UIPageViewController, but it's seems not working properly.
ios swift swift3 uipageviewcontroller
ios swift swift3 uipageviewcontroller
edited Nov 20 at 17:19
Cœur
17.4k9102144
17.4k9102144
asked Nov 19 '17 at 13:38
Felipe Santiago
5310
5310
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
That's because:
pageViewController(_:didFinishAnimating:previousViewControllers:transitionCompleted:)
method relates to UIPageViewControllerDelegate
which means that you should implement -in addition to self.dataSource = self
-:
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
// here you conform to the delegate (note that you could implement it without mentioning 'self.'):
delegate = self
AdsPageController.adsPageController = self
}
And it should work as expected. Also, make sure to let the class to conform to UIPageViewControllerDelegate
:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource, UIPageViewControllerDelegate
Furthermore, you could check this answer to be more familiar with Delegation.
Yes, i forgot that. It's working now. Thank you!
– Felipe Santiago
Nov 19 '17 at 14:31
add a 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/3.0/"u003ecc by-sa 3.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%2f47377499%2ffunc-uipageviewcontroller-didfinishanimating-not-working%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
That's because:
pageViewController(_:didFinishAnimating:previousViewControllers:transitionCompleted:)
method relates to UIPageViewControllerDelegate
which means that you should implement -in addition to self.dataSource = self
-:
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
// here you conform to the delegate (note that you could implement it without mentioning 'self.'):
delegate = self
AdsPageController.adsPageController = self
}
And it should work as expected. Also, make sure to let the class to conform to UIPageViewControllerDelegate
:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource, UIPageViewControllerDelegate
Furthermore, you could check this answer to be more familiar with Delegation.
Yes, i forgot that. It's working now. Thank you!
– Felipe Santiago
Nov 19 '17 at 14:31
add a comment |
That's because:
pageViewController(_:didFinishAnimating:previousViewControllers:transitionCompleted:)
method relates to UIPageViewControllerDelegate
which means that you should implement -in addition to self.dataSource = self
-:
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
// here you conform to the delegate (note that you could implement it without mentioning 'self.'):
delegate = self
AdsPageController.adsPageController = self
}
And it should work as expected. Also, make sure to let the class to conform to UIPageViewControllerDelegate
:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource, UIPageViewControllerDelegate
Furthermore, you could check this answer to be more familiar with Delegation.
Yes, i forgot that. It's working now. Thank you!
– Felipe Santiago
Nov 19 '17 at 14:31
add a comment |
That's because:
pageViewController(_:didFinishAnimating:previousViewControllers:transitionCompleted:)
method relates to UIPageViewControllerDelegate
which means that you should implement -in addition to self.dataSource = self
-:
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
// here you conform to the delegate (note that you could implement it without mentioning 'self.'):
delegate = self
AdsPageController.adsPageController = self
}
And it should work as expected. Also, make sure to let the class to conform to UIPageViewControllerDelegate
:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource, UIPageViewControllerDelegate
Furthermore, you could check this answer to be more familiar with Delegation.
That's because:
pageViewController(_:didFinishAnimating:previousViewControllers:transitionCompleted:)
method relates to UIPageViewControllerDelegate
which means that you should implement -in addition to self.dataSource = self
-:
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
// here you conform to the delegate (note that you could implement it without mentioning 'self.'):
delegate = self
AdsPageController.adsPageController = self
}
And it should work as expected. Also, make sure to let the class to conform to UIPageViewControllerDelegate
:
class AdsPageController: UIPageViewController,
UIPageViewControllerDataSource, UIPageViewControllerDelegate
Furthermore, you could check this answer to be more familiar with Delegation.
edited Nov 19 '17 at 13:55
answered Nov 19 '17 at 13:48
Ahmad F
15.9k104080
15.9k104080
Yes, i forgot that. It's working now. Thank you!
– Felipe Santiago
Nov 19 '17 at 14:31
add a comment |
Yes, i forgot that. It's working now. Thank you!
– Felipe Santiago
Nov 19 '17 at 14:31
Yes, i forgot that. It's working now. Thank you!
– Felipe Santiago
Nov 19 '17 at 14:31
Yes, i forgot that. It's working now. Thank you!
– Felipe Santiago
Nov 19 '17 at 14:31
add a 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f47377499%2ffunc-uipageviewcontroller-didfinishanimating-not-working%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