Author Topic: UIScrollView offset changing when applied scaling  (Read 4781 times)

gaurav.maniar

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 9
    • View Profile
UIScrollView offset changing when applied scaling
« on: August 18, 2014, 09:06:05 AM »
my scroll view is working fine on iPad, but when run my application in iPhone 5/4, i'm applying scaling to the scroll view by following code,

  1. float Scale_Ratio_X = Screen.width / 768.0f;
  2. float Scale_Ratio_Y = Screen.height / 1024.0f;
  3. float Scale_Ratio_XY = Scale_Ratio_X / Scale_Ratio_Y;
  4.  
  5. cap_scroll.transform.localScale = new Vector3(Scale_Ratio_XY, Scale_Ratio_XY, Scale_Ratio_XY);
  6. cap_scroll.transform.localPosition = new Vector3(cap_scroll.transform.localPosition.x*Scale_Ratio_XY,
  7.                                                                        cap_scroll.transform.localPosition.y*Scale_Ratio_XY, 0f);


so when i scrolling it up or down y position or offset of scroll view is getting changed, but it remains constant when testing on iPad.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView offset changing when applied scaling
« Reply #1 on: August 18, 2014, 12:27:42 PM »
Due to how clipping works (in the shader), scale must be uniform. In your case it isn't, which is what breaks them.

gaurav.maniar

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UIScrollView offset changing when applied scaling
« Reply #2 on: August 19, 2014, 12:36:34 AM »
wiil u pls elaborate.....!

my scrollview is with vertical movement, and now no problem with changing in offset values.

as u said "scale must be uniform", i have checked with all devices and x, y and z scale values are same according to screen resolution.

the actual problem is with y position of scrollview, its getting changed when scrolled up/down in devices other than screen ration 3:4.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView offset changing when applied scaling
« Reply #3 on: August 19, 2014, 11:06:56 AM »
Sorry, I misread your code. Have you tried simply scaling the parent object of the scroll view, not the scroll view itself? Also, why are you scaling it to begin with? Why not use anchors, or why not just stick to UIRoot scaling?