TableView widget: Inverted scrolling when device is rotated

I have an app which support landscapeRight, and landscapeLeft (default is landscapeRight).

The TableView scrolls correctly in landscapeRight, but when the device is rotated to landscapeLeft, the tableView’s scrolling is inverted.

The tableView is re-created from scratch in each orientation, but scrolling only works as expected in landscapeRight. [import]uid: 70847 topic_id: 34802 reply_id: 334802[/import]

I had this problem as well. If you are rotating the display yourself with the orientation event it will not work correctly. You have to allow the device to rotate the screen on it’s own. [import]uid: 56820 topic_id: 34802 reply_id: 138380[/import]

Hi,
What do you mean “Allow the device to rotate on its own”?
please provide an example, if possible

Thanks [import]uid: 135464 topic_id: 34802 reply_id: 138384[/import]

If the build.settings file is setup like below, the app rotates on its own to match the supported orientations listed.

settings =  
{  
 orientation =  
 {  
 default = "landscapeRight",  
 supported =  
 {  
 "landscapeLeft", "landscapeRight"  
 },  
 },  
}  

If you set the build.settings file to include content = “landscapeRight” (which locks the display). Then rotate the display yourself from the orientation event, scrolling will not work correctly.

That is what made my TableViews in my current app not work correctly in the manner described in the OP. I was rotating my app myself using a transition to make it look animated. When I contacted Corona support about the issue, I was told, TableViews will only scroll correctly if the app rotates the orientation automatically.

So to allow it to rotate automatically do not include content=“whateverOrientation” and do not attempt to rotate the display in your code. [import]uid: 56820 topic_id: 34802 reply_id: 138390[/import]

Hi,
Thanks for the fast reply.
I apologize, but I’m still a bit confused about the solution.
Can you post a short code sample ?
Again, thank you very much [import]uid: 135464 topic_id: 34802 reply_id: 138396[/import]

Ugh! Yeah, that works…but it results in what I call “Ugly Android Rotation”. Instant rotation without animation. Plus on iOS it’s even worse since you get a rotating black rectangle without content…

I still think it should be considered a bug that can be fixed.

A suggestion would be to add something like a .isInverted property so that we can handle this ourselves.
[import]uid: 70847 topic_id: 34802 reply_id: 138417[/import]

OK. I managed to get the autorotation to work *with* animation and keep the functionality of the tableview :slight_smile: So far I haven’t seen any negative side-effects.

As @anderoth said, you’ll first need to remove the “content=” setting from build.settings.

I then used my autorotation.lua which checks for orientation changes and performs the animation. I’ve written my own, but there are others available in the Corona Code library somewhere… just don’t remember where.
The trick is to set the stage to 180 degrees rotation just before you want the animation to occur. This works since Corona rotates the stage instantly. By setting stage.rotation=180, we’re just setting the stage back to where it was before Corona rotated it. Then we apply our animation as before which will rotate it back to 0 causing the tableview to behave correctly.

I also added a condition to skip adding the eventhandler for orientation changes on Android devices since the “black frame” rotation issue is only present on iOS.

I’m still not sure if there are any negative side-effects of doing this, but so far I haven’t seen any. [import]uid: 70847 topic_id: 34802 reply_id: 138437[/import]

Clever ingemar!

I never really took it any further. That’s a nice work around. Let us know if you run into any side effects down the line. [import]uid: 56820 topic_id: 34802 reply_id: 138483[/import]

I had this problem as well. If you are rotating the display yourself with the orientation event it will not work correctly. You have to allow the device to rotate the screen on it’s own. [import]uid: 56820 topic_id: 34802 reply_id: 138380[/import]

Hi,
What do you mean “Allow the device to rotate on its own”?
please provide an example, if possible

Thanks [import]uid: 135464 topic_id: 34802 reply_id: 138384[/import]

If the build.settings file is setup like below, the app rotates on its own to match the supported orientations listed.

settings =  
{  
 orientation =  
 {  
 default = "landscapeRight",  
 supported =  
 {  
 "landscapeLeft", "landscapeRight"  
 },  
 },  
}  

If you set the build.settings file to include content = “landscapeRight” (which locks the display). Then rotate the display yourself from the orientation event, scrolling will not work correctly.

That is what made my TableViews in my current app not work correctly in the manner described in the OP. I was rotating my app myself using a transition to make it look animated. When I contacted Corona support about the issue, I was told, TableViews will only scroll correctly if the app rotates the orientation automatically.

So to allow it to rotate automatically do not include content=“whateverOrientation” and do not attempt to rotate the display in your code. [import]uid: 56820 topic_id: 34802 reply_id: 138390[/import]

Hi,
Thanks for the fast reply.
I apologize, but I’m still a bit confused about the solution.
Can you post a short code sample ?
Again, thank you very much [import]uid: 135464 topic_id: 34802 reply_id: 138396[/import]

Ugh! Yeah, that works…but it results in what I call “Ugly Android Rotation”. Instant rotation without animation. Plus on iOS it’s even worse since you get a rotating black rectangle without content…

I still think it should be considered a bug that can be fixed.

A suggestion would be to add something like a .isInverted property so that we can handle this ourselves.
[import]uid: 70847 topic_id: 34802 reply_id: 138417[/import]

OK. I managed to get the autorotation to work *with* animation and keep the functionality of the tableview :slight_smile: So far I haven’t seen any negative side-effects.

As @anderoth said, you’ll first need to remove the “content=” setting from build.settings.

I then used my autorotation.lua which checks for orientation changes and performs the animation. I’ve written my own, but there are others available in the Corona Code library somewhere… just don’t remember where.
The trick is to set the stage to 180 degrees rotation just before you want the animation to occur. This works since Corona rotates the stage instantly. By setting stage.rotation=180, we’re just setting the stage back to where it was before Corona rotated it. Then we apply our animation as before which will rotate it back to 0 causing the tableview to behave correctly.

I also added a condition to skip adding the eventhandler for orientation changes on Android devices since the “black frame” rotation issue is only present on iOS.

I’m still not sure if there are any negative side-effects of doing this, but so far I haven’t seen any. [import]uid: 70847 topic_id: 34802 reply_id: 138437[/import]

Clever ingemar!

I never really took it any further. That’s a nice work around. Let us know if you run into any side effects down the line. [import]uid: 56820 topic_id: 34802 reply_id: 138483[/import]

Hey Ingemar
Just want to say thanks for figuring this rotation issue out and posting your simple solution.
Ugly rotation on ios have been bugging me for a while.
Your solution seems to work just fine with the rotationfix from the code exchange.
[import]uid: 13632 topic_id: 34802 reply_id: 143126[/import]

Hey Ingemar
Just want to say thanks for figuring this rotation issue out and posting your simple solution.
Ugly rotation on ios have been bugging me for a while.
Your solution seems to work just fine with the rotationfix from the code exchange.
[import]uid: 13632 topic_id: 34802 reply_id: 143126[/import]

Hey Ingemar
Just want to say thanks for figuring this rotation issue out and posting your simple solution.
Ugly rotation on ios have been bugging me for a while.
Your solution seems to work just fine with the rotationfix from the code exchange.
[import]uid: 13632 topic_id: 34802 reply_id: 143126[/import]

Hey Ingemar
Just want to say thanks for figuring this rotation issue out and posting your simple solution.
Ugly rotation on ios have been bugging me for a while.
Your solution seems to work just fine with the rotationfix from the code exchange.
[import]uid: 13632 topic_id: 34802 reply_id: 143126[/import]

Ingemar, 

you just saved me from madness :slight_smile:

Thank you so much for sharing this!

Emerson