How to change simulator orientation at run time?

Is it possible to change Corona simulator orientation when it’s running?

This might be a simple question but I couldn’t find the answer after I searched the web. I saw there are two simulator options in “Hardware” -> Rotate Left & Rotate Right, but they are not actually changing orientation.

Thanks.

Yes, those are the right options to make the simulator rotate. What build are you using? When you say it doesn’t change the orientation, what happens instead?

Maybe I am missing something.

If I run my app with landscape mode,

orientation = { default = "landscape", supported = { "portrait", "landscape" } },

It starts as landscape and runs fine.

And if I start the app as “portrait”, it runs fine too. So I thought when the orientation happens, the process would be taken care of automatically.

But it seems not, because when I choose the option “Hardware->Rotate Left” (or Rotate Right), the app screen goes wrong.

I think I have to do something in the code when the orientation happens, but I don’t.

Runtime:addEventListener( "orientation", onOrientationChange )

Is this what I should take care of no matter what?

OK, so the simulator is in fact rotating, it’s just that the result isn’t what you expected.

If your app runs in both portrait and landscape, it’s up to you to listen for orientation events and rearrange your content when the orientation changes.  You can do that by listening to orientation events, like in your post, or even better, you can listen to so-called resize events (http://docs.coronalabs.com/api/event/resize/index.html).

  • Andrew

Yes, those are the right options to make the simulator rotate. What build are you using? When you say it doesn’t change the orientation, what happens instead?

Maybe I am missing something.

If I run my app with landscape mode,

orientation = { default = "landscape", supported = { "portrait", "landscape" } },

It starts as landscape and runs fine.

And if I start the app as “portrait”, it runs fine too. So I thought when the orientation happens, the process would be taken care of automatically.

But it seems not, because when I choose the option “Hardware->Rotate Left” (or Rotate Right), the app screen goes wrong.

I think I have to do something in the code when the orientation happens, but I don’t.

Runtime:addEventListener( "orientation", onOrientationChange )

Is this what I should take care of no matter what?

OK, so the simulator is in fact rotating, it’s just that the result isn’t what you expected.

If your app runs in both portrait and landscape, it’s up to you to listen for orientation events and rearrange your content when the orientation changes.  You can do that by listening to orientation events, like in your post, or even better, you can listen to so-called resize events (http://docs.coronalabs.com/api/event/resize/index.html).

  • Andrew

I notice that text and image could be resized but some other (like tabBar, scrollView) were not.

So i just remove the currents, then insert some new adjusted ones. Is there a better way?

Could you please share about the most common and effective way to rearrange the content?

I notice that text and image could be resized but some other (like tabBar, scrollView) were not.

So i just remove the currents, then insert some new adjusted ones. Is there a better way?

Could you please share about the most common and effective way to rearrange the content?