AirCode supportedOrientations()

@Simeon Remember this thread? Inside this app I use a special function to mirror my canvas. It works by rotating the device by 180°. Therefor, on app start, I support only 2 orientations - the current and its opposite. Here’s the code:

supportedOrientations(CurrentOrientation, (CurrentOrientation~=3 and CurrentOrientation~=1) and CurrentOrientation+1 or CurrentOrientation-1)

```


..which is working just fine when I run the app from Codea directly. But if I run it from AirCode, the statement gets ignored at all!

Is it outside a function, or in setup? It will only get ran once, then, a big feature of AirCode is to edit the code while the project is running. Wouldn’t it be weird if every time you changed the code, it restarted the app?

It is outside the setup() function. Right at the beginning of the codebase - so it should be run only once! But that is not the point. This statement is totally ignored by AirCode… But since Codea understands it, so should AirCode.

@se24vad But, again, that would require restarting your project whenever you made a change. I don’t see why you would even change the supportedOrientations while in the middle of coding in AirCode. If you want it to update for some reason, press CTRL+R or CMD+R to restart the project. Either way, it’s not a bug.

Excuse me @SkyTheCoder but I seem not to understand you :smiley:
Could you try the fallowing code inside Codea and through AirCode? While testing the app, rotate your iPad, and then report back what you observed, please!

https://gist.github.com/jack0088/d19e20c53c20e63c8412

@se24vad I don’t have my iPad with me right now, but I don’t think it’s a bug. Anything inside setup or outside any other function will never get ran a second time in AirCode. You can try restarting with CTRL+R or CMD+R, but I don’t think that would work, because supportedOrientations can only be ran one time, before or in setup (running it a second time doesn’t do anything, I know this from experience). I think it’s something to do with iOS not letting you change the supported orientations while the app is running.

@SkyTheCoder I know that, I’m using Codea quite a some time now. The thing is: By default ALL supportedOrientations are alowed. When calling supportedOrientations() and pass any params, the iPad will be restricted to those orientations. As you said, it would be senseless to call this function more than one time! And so I’m calling it only once - right before the setup(), to make sure, the ipad starts by default with the current orientation!

Assume I run my app in landscape_left mode. This works fine from Codea directly. But when I run my project from inside Aircode, also in landscape_left, it runs actually in portrait mode! Besides that, regardless of my supportedOrientations() restriction, I’m able to freely rotate my iPad and change its orientation.

Hope you now understand me…

@se24vad What I’m saying is, AirCode loads the code after starting running a blank app, then restarts it. Since it loaded the code that says to connect your browser to a certain IP, it’s already running, with supportedOrientations as ANY. It doesn’t let you call it again, so it leaves it as ANY.

@SkyTheCoder ohh… I finally got you! But again its a weird behavior then, isn’t it? Why no connect, and then run everything

PS: I edited the thread title, since it seems to be normal, but for me its weird approach anyway