UITabBarController's viewControllers present modal controller issue











up vote
0
down vote

favorite












I have a UITabBarController with 4 viewControllers setup.



One of the controller has a button that present another controller (wrapped on UINavigationController) with the following setup:



self.definesPresentationContext = true
navController.modalPresentationStyle = .overCurrentContext
navController.modalTransitionStyle = .crossDissolve
self.present(navController, animated: true)


Until this point is working fine.



Now if I switch to another tab (while the previous modal is open), and return again to the tab that presented the modal (The screen is still there, that's ok). Then if i close the modal (from a Button), the modal is dismissed but the controller view's has gone (white), then if I switch to another tab and return to the tab again, the view load correctly.



Note: For this case, I need overCurrentContext, don't want to block UITabBarController (with fullScreen).. Also try with .currentContext, custom










share|improve this question






















  • I believe this is a well-known bug.
    – matt
    Jun 8 at 16:51










  • @matt actually was reading your book (I took as coobook :) and was waiting you for answer ).. Thanks for comment. Any idea?
    – José Roberto Abreu
    Jun 8 at 16:53












  • If it's the same bug, I give my workaround, which is to prevent the user from doing that — i.e. the user cannot switch to another tab while the modal is open. See github.com/mattneub/Programming-iOS-Book-Examples/blob/master/…
    – matt
    Jun 8 at 16:56










  • @matt Select your answer as correct, for mentioning that this is a known bug.. In my case, I can't force the TabBar (due to UX) from switching. As a workaround, I did the following: Dismiss the presented controller when the Tab is switched and the modalPresentationStyle is .overCurrentContext.
    – José Roberto Abreu
    Jun 8 at 19:42












  • That's good too, obviously! Equally valid. You might give that as an alternate answer, for the record.
    – matt
    Jun 8 at 19:44















up vote
0
down vote

favorite












I have a UITabBarController with 4 viewControllers setup.



One of the controller has a button that present another controller (wrapped on UINavigationController) with the following setup:



self.definesPresentationContext = true
navController.modalPresentationStyle = .overCurrentContext
navController.modalTransitionStyle = .crossDissolve
self.present(navController, animated: true)


Until this point is working fine.



Now if I switch to another tab (while the previous modal is open), and return again to the tab that presented the modal (The screen is still there, that's ok). Then if i close the modal (from a Button), the modal is dismissed but the controller view's has gone (white), then if I switch to another tab and return to the tab again, the view load correctly.



Note: For this case, I need overCurrentContext, don't want to block UITabBarController (with fullScreen).. Also try with .currentContext, custom










share|improve this question






















  • I believe this is a well-known bug.
    – matt
    Jun 8 at 16:51










  • @matt actually was reading your book (I took as coobook :) and was waiting you for answer ).. Thanks for comment. Any idea?
    – José Roberto Abreu
    Jun 8 at 16:53












  • If it's the same bug, I give my workaround, which is to prevent the user from doing that — i.e. the user cannot switch to another tab while the modal is open. See github.com/mattneub/Programming-iOS-Book-Examples/blob/master/…
    – matt
    Jun 8 at 16:56










  • @matt Select your answer as correct, for mentioning that this is a known bug.. In my case, I can't force the TabBar (due to UX) from switching. As a workaround, I did the following: Dismiss the presented controller when the Tab is switched and the modalPresentationStyle is .overCurrentContext.
    – José Roberto Abreu
    Jun 8 at 19:42












  • That's good too, obviously! Equally valid. You might give that as an alternate answer, for the record.
    – matt
    Jun 8 at 19:44













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a UITabBarController with 4 viewControllers setup.



One of the controller has a button that present another controller (wrapped on UINavigationController) with the following setup:



self.definesPresentationContext = true
navController.modalPresentationStyle = .overCurrentContext
navController.modalTransitionStyle = .crossDissolve
self.present(navController, animated: true)


Until this point is working fine.



Now if I switch to another tab (while the previous modal is open), and return again to the tab that presented the modal (The screen is still there, that's ok). Then if i close the modal (from a Button), the modal is dismissed but the controller view's has gone (white), then if I switch to another tab and return to the tab again, the view load correctly.



Note: For this case, I need overCurrentContext, don't want to block UITabBarController (with fullScreen).. Also try with .currentContext, custom










share|improve this question













I have a UITabBarController with 4 viewControllers setup.



One of the controller has a button that present another controller (wrapped on UINavigationController) with the following setup:



self.definesPresentationContext = true
navController.modalPresentationStyle = .overCurrentContext
navController.modalTransitionStyle = .crossDissolve
self.present(navController, animated: true)


Until this point is working fine.



Now if I switch to another tab (while the previous modal is open), and return again to the tab that presented the modal (The screen is still there, that's ok). Then if i close the modal (from a Button), the modal is dismissed but the controller view's has gone (white), then if I switch to another tab and return to the tab again, the view load correctly.



Note: For this case, I need overCurrentContext, don't want to block UITabBarController (with fullScreen).. Also try with .currentContext, custom







ios swift uiviewcontroller uimodalpresentationstyle






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 8 at 16:50









José Roberto Abreu

3117




3117












  • I believe this is a well-known bug.
    – matt
    Jun 8 at 16:51










  • @matt actually was reading your book (I took as coobook :) and was waiting you for answer ).. Thanks for comment. Any idea?
    – José Roberto Abreu
    Jun 8 at 16:53












  • If it's the same bug, I give my workaround, which is to prevent the user from doing that — i.e. the user cannot switch to another tab while the modal is open. See github.com/mattneub/Programming-iOS-Book-Examples/blob/master/…
    – matt
    Jun 8 at 16:56










  • @matt Select your answer as correct, for mentioning that this is a known bug.. In my case, I can't force the TabBar (due to UX) from switching. As a workaround, I did the following: Dismiss the presented controller when the Tab is switched and the modalPresentationStyle is .overCurrentContext.
    – José Roberto Abreu
    Jun 8 at 19:42












  • That's good too, obviously! Equally valid. You might give that as an alternate answer, for the record.
    – matt
    Jun 8 at 19:44


















  • I believe this is a well-known bug.
    – matt
    Jun 8 at 16:51










  • @matt actually was reading your book (I took as coobook :) and was waiting you for answer ).. Thanks for comment. Any idea?
    – José Roberto Abreu
    Jun 8 at 16:53












  • If it's the same bug, I give my workaround, which is to prevent the user from doing that — i.e. the user cannot switch to another tab while the modal is open. See github.com/mattneub/Programming-iOS-Book-Examples/blob/master/…
    – matt
    Jun 8 at 16:56










  • @matt Select your answer as correct, for mentioning that this is a known bug.. In my case, I can't force the TabBar (due to UX) from switching. As a workaround, I did the following: Dismiss the presented controller when the Tab is switched and the modalPresentationStyle is .overCurrentContext.
    – José Roberto Abreu
    Jun 8 at 19:42












  • That's good too, obviously! Equally valid. You might give that as an alternate answer, for the record.
    – matt
    Jun 8 at 19:44
















I believe this is a well-known bug.
– matt
Jun 8 at 16:51




I believe this is a well-known bug.
– matt
Jun 8 at 16:51












@matt actually was reading your book (I took as coobook :) and was waiting you for answer ).. Thanks for comment. Any idea?
– José Roberto Abreu
Jun 8 at 16:53






@matt actually was reading your book (I took as coobook :) and was waiting you for answer ).. Thanks for comment. Any idea?
– José Roberto Abreu
Jun 8 at 16:53














If it's the same bug, I give my workaround, which is to prevent the user from doing that — i.e. the user cannot switch to another tab while the modal is open. See github.com/mattneub/Programming-iOS-Book-Examples/blob/master/…
– matt
Jun 8 at 16:56




If it's the same bug, I give my workaround, which is to prevent the user from doing that — i.e. the user cannot switch to another tab while the modal is open. See github.com/mattneub/Programming-iOS-Book-Examples/blob/master/…
– matt
Jun 8 at 16:56












@matt Select your answer as correct, for mentioning that this is a known bug.. In my case, I can't force the TabBar (due to UX) from switching. As a workaround, I did the following: Dismiss the presented controller when the Tab is switched and the modalPresentationStyle is .overCurrentContext.
– José Roberto Abreu
Jun 8 at 19:42






@matt Select your answer as correct, for mentioning that this is a known bug.. In my case, I can't force the TabBar (due to UX) from switching. As a workaround, I did the following: Dismiss the presented controller when the Tab is switched and the modalPresentationStyle is .overCurrentContext.
– José Roberto Abreu
Jun 8 at 19:42














That's good too, obviously! Equally valid. You might give that as an alternate answer, for the record.
– matt
Jun 8 at 19:44




That's good too, obviously! Equally valid. You might give that as an alternate answer, for the record.
– matt
Jun 8 at 19:44












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










If this is the same bug that I demonstrate here, the workaround I give is to prevent the user from switching to another tab while this tab is showing the presented view controller:



override func viewDidLoad() {
super.viewDidLoad()
self.tabBarController?.delegate = self
}
extension FirstViewController : UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
return self.presentedViewController == nil
}
}





share|improve this answer





















    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',
    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
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50765226%2fuitabbarcontrollers-viewcontrollers-present-modal-controller-issue%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








    up vote
    1
    down vote



    accepted










    If this is the same bug that I demonstrate here, the workaround I give is to prevent the user from switching to another tab while this tab is showing the presented view controller:



    override func viewDidLoad() {
    super.viewDidLoad()
    self.tabBarController?.delegate = self
    }
    extension FirstViewController : UITabBarControllerDelegate {
    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
    return self.presentedViewController == nil
    }
    }





    share|improve this answer

























      up vote
      1
      down vote



      accepted










      If this is the same bug that I demonstrate here, the workaround I give is to prevent the user from switching to another tab while this tab is showing the presented view controller:



      override func viewDidLoad() {
      super.viewDidLoad()
      self.tabBarController?.delegate = self
      }
      extension FirstViewController : UITabBarControllerDelegate {
      func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
      return self.presentedViewController == nil
      }
      }





      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        If this is the same bug that I demonstrate here, the workaround I give is to prevent the user from switching to another tab while this tab is showing the presented view controller:



        override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBarController?.delegate = self
        }
        extension FirstViewController : UITabBarControllerDelegate {
        func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        return self.presentedViewController == nil
        }
        }





        share|improve this answer












        If this is the same bug that I demonstrate here, the workaround I give is to prevent the user from switching to another tab while this tab is showing the presented view controller:



        override func viewDidLoad() {
        super.viewDidLoad()
        self.tabBarController?.delegate = self
        }
        extension FirstViewController : UITabBarControllerDelegate {
        func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        return self.presentedViewController == nil
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 8 at 16:57









        matt

        318k44513716




        318k44513716






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50765226%2fuitabbarcontrollers-viewcontrollers-present-modal-controller-issue%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







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()