iOS Question Disable AutoRotate if the controller is the SideMenuController

Discussion in 'iOS Questions' started by Filippo, Sep 16, 2018.

  1. Filippo

    Filippo Expert Licensed User


    How can you disable AutoRotate if the controller is the SideMenuController?

    Since I changed the NavigationController and use a SideMenuController, the Sub Main_ShouldAutoRotate is no longer executed.
    How can I fix the problem?

    Sub Process_Globals
    'These global variables will be declared once when the application starts.
        'Public variables can be accessed from all modules.
        Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private Page2 As Page
    Private smc As SideMenuController
    Private pMenu As Page
    End Sub

    Private Sub Application_Start (Nav As NavigationController)
        NavControl.NavigationBarVisible = 
        Page2.RootPanel.Color = 

        smc.Initialize(pMenu, NavControl, 
        App.KeyController = smc
    End Sub

    Sub Page1_Click
    End Sub

    Sub Main_ShouldAutoRotate As Boolean
    If Page2.Visible = True Then
    Return False 'Don't auto rotate if Page2 is visible
    Return True
    End If
    End Sub

    #if OBJC
    @interface UINavigationController (B4IResize)

    @implementation UINavigationController (B4IResize)
    - (BOOL)shouldAutorotate
      return [(NSNumber*)[B4IObjectWrapper raiseEvent:self :@"_shouldautorotate" :nil] boolValue];

    #End If
    Last edited: Sep 17, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

    1. Add this code to the main module:
    #if OBJC
    @interface UIViewController (B4IResize)

    @implementation UIViewController (B4IResize)
    - (BOOL)shouldAutorotate
       if ([self isKindOfClass:NSClassFromString(@"MMDrawerController")]) {
           NSDictionary* map = [B4IObjectWrapper getMap:self];
           NSNumber* n = map[@"tag"];
           return n.boolValue;
       return true;

    #End If
    2. Set smc.Tag to True or False. True = autorotate, False = no autorotate.
    Filippo likes this.
  3. Filippo

    Filippo Expert Licensed User

    Hello Erel,
    Thanks for the modified routine.
    But I have problems with the implementation, it does not work as easily as with the routine of the standard NavigationController.

    I'll try a bit more, if it does not work then I'll remove the SideMenuController.
  4. Filippo

    Filippo Expert Licensed User

    Hi Erel,

    After many tests I finally solved it, thanks again. :)

    The implementation was a bit complicated but still feasible.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice