iOS Question shouldAutorotate causes app to shutdown immediately

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.
B4X:
#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?
 

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:
B4X:
2019-04-29 09:20:53.490148+0100 B4iProject[1197:159096] didFinishLaunchingWithOptions
 

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:
B4X:
'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:
B4X:
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
 
Top