Giter Site home page Giter Site logo

Comments (11)

supergenedy avatar supergenedy commented on June 17, 2024 5

I made a solution for this issue till MoathOthman updates the lib
you can add this func in your AppDelegate it gets the window from SceneDelegate

 @available(iOS 13.0, *)
    func swichRoot(){
        //Flip Animation before changing rootView
        animateView()

        // switch root view controllers
        let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
        let nav = storyboard.instantiateViewController(withIdentifier: "HomeView")
        
        let scene = UIApplication.shared.connectedScenes.first
        if let sd : SceneDelegate = (scene?.delegate as? SceneDelegate) {
            sd.window!.rootViewController = nav
        }
        
    }
   @available(iOS 13.0, *)
    func animateView() {
        var transition = UIView.AnimationOptions.transitionFlipFromRight
        if !MOLHLanguage.isRTLLanguage() {
            transition = .transitionFlipFromLeft
        }
       animateView(transition: transition)
    }
    
    @available(iOS 13.0, *)
    func animateView(transition: UIView.AnimationOptions) {
        if let delegate = UIApplication.shared.connectedScenes.first?.delegate {
            UIView.transition(with: (((delegate as? SceneDelegate)!.window)!), duration: 0.5, options: transition, animations: {}) { (f) in
            }
        }
    }

You can check if ios > 13 then call this func from the AppDelegate

        if #available(iOS 13.0, *) {
                let delegate = UIApplication.shared.delegate as? AppDelegate
                delegate!.swichRoot()
        } else {
               // Fallback on earlier versions
               MOLH.reset()
        }

And also check if ios > 13 in the reset func in the AppDelegate to call swichRoot func

from molh.

fo24 avatar fo24 commented on June 17, 2024 1

@MoathOthman i already uploaded the project in github i will invite you.

from molh.

MoathOthman avatar MoathOthman commented on June 17, 2024 1

@fo24
This behavior occurs because with the new scene delegate, since now on ipados an app can have multiple scenes and hence multiple rootviewcontroller so there is no shared uiapplication that has a single rootviewcontroller anymore. if you are target ios 12 or you are not supporting iPadOS or you don't want to support multiple windows , then you can remove all the scene delegates code and you should be fine .. i pushed the code in a new branch on ur repo.
This is causing an issue in the library as well and i will try to fix it soon.
thnx

from molh.

MoathOthman avatar MoathOthman commented on June 17, 2024

@fo24 can you provide more info, e.g. which xcode version , and ios , are you using scene delegate because i have not tried it there yet ?

from molh.

fo24 avatar fo24 commented on June 17, 2024

@MoathOthman Many thanks for reply. i work with Xcode11 and swift5
And this is my AppDelegate
`import UIKit
import MOLH

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate ,MOLHResetable {
var window: UIWindow?
func reset() {
let rootviewcontroller: UIWindow = ((UIApplication.shared.delegate?.window)!)!
let stry = UIStoryboard(name: "Main", bundle: nil)
rootviewcontroller.rootViewController = stry.instantiateViewController(withIdentifier: "rootnav") }

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    MOLH.shared.activate(true)
   
    return true
}`

from molh.

MoathOthman avatar MoathOthman commented on June 17, 2024

@fo24 are you using the demo project? i think you might have forgotten to set the initial view controller in the main storyboard or something like that.

from molh.

fo24 avatar fo24 commented on June 17, 2024

Main storyboard 2019-10-09 10-26-42
@MoathOthman I already make it but in app delegate i added var window: UIwindow? manually

from molh.

MoathOthman avatar MoathOthman commented on June 17, 2024

@fo24 I will try to start the project with xcode11 and see what is the issue, if you could solve it as well before, please let us know here ! thnx

from molh.

fo24 avatar fo24 commented on June 17, 2024

Many thnx i will close the issue.

from molh.

MoathOthman avatar MoathOthman commented on June 17, 2024

your welcome :)

from molh.

Emy87aa avatar Emy87aa commented on June 17, 2024

Did you solved it, because i'm facing the same problem now.

from molh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.