iOS Question shouldAutorotate causes app to shutdown immediately

Discussion in 'iOS Questions' started by CaptKronos, Apr 28, 2019.

  1. CaptKronos

    CaptKronos Active Member Licensed User

    I believe I am running into a similar problem to what was reported here https://www.b4x.com/android/forum/threads/method-not-found-audiovol_hide.94401/#content

    When I add the following to the bottom of my main module the release version of the app appears for a split second before shutting down. No error appears in the log. Running the debug version of the app and all is fine.
    Code:
    #if OBJC
    @end
    @interface UINavigationController (B4IResize)

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

    #End If
    Erel's response to the above referenced thread was to add the code after any other inline code. My main module doesn't have any inline code but several other modules in the project do. In which case, where should I place the shouldAutorotate code?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Other modules shouldn't matter. Are you able to reproduce it with a small project?
     
  3. CaptKronos

    CaptKronos Active Member Licensed User

    I thought you would ask for that - I'll see what I can do. One thing I didn't mention in my previous post was that the only entry that appears in the log before the app shuts down is:
    Code:
    2019-04-29 09:20:53.490148+0100 B4iProject[1197:159096] didFinishLaunchingWithOptions
     
  4. CaptKronos

    CaptKronos Active Member Licensed User

    Ok, I now know how to replicate the problem. Not sure if this is a bug or if I'm doing something that I shouldn't be.

    Within the test to determine whether to allow the rotation I have been examining a variable declared in another code module. It is this reference that is causing the problem. If I don't reference another module then all is fine.

    Module test.bas:
    Code:
    'Code module

    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'Public variables can be accessed from all modules.
        Public num As Int=1
    End Sub
    and main:
    Code:
    Sub Main_ShouldAutoRotate As Boolean
        
    If test.num=1 Then
            
    Return False
        
    Else
            
    Return True
        
    End If
    End Sub

    #if OBJC
    @end
    @interface UINavigationController (B4IResize)

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

    #End If
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    It is probably called before the modules are ready.
     
Loading...
  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