fortmarek / SwipeViewController

SwipeViewController is a Swift modification of RKSwipeBetweenViewControllers - navigate between pages / ViewControllers
MIT License
655 stars 46 forks source link

How can I do without "didFinishLaunchingWithOptions"? #26

Closed relaxsus closed 6 years ago

relaxsus commented 6 years ago

How can I do without "didFinishLaunchingWithOptions"? For example, how can I call my SwipeViewController in the viewDidAppear method? When the application starts, the first window I have authorization, and then I need to work with SwipeViewController.

fortmarek commented 6 years ago

You can init the SwipeViewController simply like this:

let pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
let navigationController = YourViewControllerName(rootViewController: pageController)

You can do this wherever you want, I guess I should make it more clear from the documentation.

relaxsus commented 6 years ago
override func viewDidAppear(_ animated: Bool) {
        super .viewDidAppear(animated)
        let pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
        let navigationController = ViewController(rootViewController: pageController)
        self.present(navigationController, animated:false, completion: nil)  
    }

this code does not work :( Please tell me what my mistake is, or how to write better :( I'm a beginner programmer, please forgive me :(

fortmarek commented 6 years ago

And what exactly does not work? I tried to present SwipeViewController in my code and it worked. Maybe there is something wrong in your ViewController regarding the setting of SwipeViewController.

fortmarek commented 6 years ago

But if you have authorization window, I think it would be better to first set AuthorizationViewController and then set it rootViewController to whatever your next viewcontroller is. Like this:

let window = UIApplication.shared.keyWindow
window?.rootViewController = YourViewController()
window?.makeKeyAndVisible()
relaxsus commented 6 years ago

Only the first screen is displayed, but nothing is pressed. If you put 'animated: true', then an infinite number of times is shown

fortmarek commented 6 years ago

...are you calling that in ViewController? Because then it would make sense (every time the view appears, it calls viewDidAppear again, etc., etc.)

relaxsus commented 6 years ago

Yes, you are right. How then to be? at what point it is better to call?

fortmarek commented 6 years ago

I do not really understand what you are trying to achieve. You said that you have an authorizationviewcontroller from which you want to present SwipeViewController, is that right? Well, then in you AuthorizationViewController, for example when user taps loginButton, present SwipeViewController.

relaxsus commented 6 years ago

Oh my God, forgive me for taking your time, I,ve found a mistake after your last message. That was such a petty mistake .... You are a wonderful person and a programmer! Thank you very much! Everything is working!

fortmarek commented 6 years ago

Great! Glad to be of help, hit me up if you encounter any more problems 😉

relaxsus commented 6 years ago

2017-12-18 18 13 55 Could you tell me pleeeease, how I can add the TabBarController to the hierarchy? I mean that the main Navigation is my TabBar with bottom switching. And after that is SwipeViewController.

fortmarek commented 6 years ago

I do not use storyboard and I have not tried that yet, you have to basically replicate this part:

let pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
let navigationController = YourViewControllerName(rootViewController: pageController)

My guess is that it would go something like this: TabBarController -> SwipeViewController -> (rootViewController) UIPageViewController

fortmarek commented 6 years ago

Umm, you do not have to present navigationController from your tabBarController, that is handled by UIKit itself. Just set tabBarController.viewCountrollers = Array and then present that tabBarController.

On Dec 19, 2017, at 8:59 AM, relaxsus notifications@github.com wrote:

Good afternoon. Could you tell me please, how is it possible to write the code? :( I wrote this code, but it does not work, because I do not know how to process tabBar = ( I excuse me for taking your time :( override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if (segue.identifier == "show") { if let tabBarController = segue.destination as? UITabBarController { let pageController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) let navigationController = ViewController(rootViewController: pageController) self.present(navigationController, animated: true, completion: nil) } } }

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/fortmarek/SwipeViewController/issues/26#issuecomment-352667421, or mute the thread https://github.com/notifications/unsubscribe-auth/AI8AL1E2RyzQNyjixctl13TUF7vcybBSks5tB2zigaJpZM4RFQ41.

relaxsus commented 6 years ago

Yes, I eventually read a lot of information, and did the same. Therefore, I deleted the question. You are a great person. I feel uncomfortable. Thank you very much.

fortmarek commented 6 years ago

I see, I answered right from the email, so I did not notice it had been already deleted. Anyway, starting programming is a difficult task, so do not feel bad for asking questions and no question is stupid. Keep learning ✌

On Dec 19, 2017, at 12:52 PM, relaxsus notifications@github.com wrote:

Yes, I eventually read a lot of information, and did the same. Therefore, I deleted the question. You are a great person. I feel uncomfortable. Thank you very much.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/fortmarek/SwipeViewController/issues/26#issuecomment-352728023, or mute the thread https://github.com/notifications/unsubscribe-auth/AI8AL8OLBBNSQ8cq4eHsJs7wUY9DELcOks5tB6NmgaJpZM4RFQ41.

fortmarek commented 6 years ago

I see, I answered right from the email, so I did not notice it had been already deleted. Anyway, starting programming is a difficult task, so do not feel bad for asking questions and no question is stupid. Keep learning ✌

On Dec 19, 2017, at 12:52 PM, relaxsus <notifications@github.com mailto:notifications@github.com> wrote:

Yes, I eventually read a lot of information, and did the same. Therefore, I deleted the question. You are a great person. I feel uncomfortable. Thank you very much.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/fortmarek/SwipeViewController/issues/26#issuecomment-352728023, or mute the thread https://github.com/notifications/unsubscribe-auth/AI8AL8OLBBNSQ8cq4eHsJs7wUY9DELcOks5tB6NmgaJpZM4RFQ41.