I am in need of changing location of components in my app depending on the screen orientation. It seems to be an easy task, but I had been struggling for hours. I think I finally confirm that it is indeed a bug. I have attached a screenshot of the code to demonstrate.
The basic idea is that if Screen.Height > Screen.Width, then it's in portrait mode. It reports fine "when Screen.Initialize", but reported just the opposite orientation in "when Screen. ScreenOrientationChanged" - and it seems that the Height and Width are not set correctly, unless of course if I miss something.
If any can confirms that I am not missing anything, and it's indeed a bug, please let me know how to report this.
--
There's a delay between the physical orientation change and the reporting. It's not really a bug, but it's not a good thing either.
What we usually do is create a clock and enable it when the orientation changes. That clock is set to half second, 500 ms (or whatever works for you).
Inside the Clock.Timer event, by now you should have the width and height values updated, so do what you have to do when the orientation changes. This gives half second to the app to receive the new orientation and be able to report it correctly.
I hope it works for you.
--
Thank you, Italo - your suggestion works perfectly. I have attached the sample code with your suggestion for the benefit other users.
--
However, I believe it should be considered as a bug and being addressed - I mean "when Screen .ScreenOrientationChanged" event should only be fired when Screen.Width and Screen.Height are updated - in this case, approximately 500 msec. after it is fired right now. Otherwise, all the users will have to have the timer added (as you suggested) in order to get an accurate reading of Screen.Width and Screen.Height.
Thanks again Italo for your quick reply with a simple solution.
댓글 없음:
댓글 쓰기