Picker Wheel Does Not Stay in Place

I am using a plain vanilla picker wheel widget with no customization. The widget allows my users to enter their birthday when signing up for an account. Everything works as far as values, days, years, etc. on both IOS and Android. My issue is that it will not stay in place, i.e. the top left corner will either be in the correct location or it will jump to the center of the screen causing the picker wheel to go off to the right of the screen.

The strange part is there is no rhyme or reason as to why it happens or when it will happen. I can do a build and it will work just fine for that build. But the very next build it may (or may not) move the top left corner of the widget to the center of the screen and it will be wrong for everyone. I simply do another build without changing a thing and it will be back in the correct position.

Being a typical guy with a typical bad memory, I do not always remember to check it before I publish my app so it may get published with the bad alignment.

I have tried both of the following and the results are the same:

top = 120, left = 0, x = display.contentWidth \* .5, y = display.contentHeight \* .5,

Has anyone seen this issue before? Below is my code.

Thanks ahead of time,

Scott

local dobMM = 06 local dobDD = 15 local dobYYidx = 50 local startYear = 1930 if (not pickerGroup) then pickerGroup = display.newGroup() end -- Create two tables to hold data for days and years local days = {} local years = {} -- Populate the "days" table for d = 1, 31 do days[d] = d end -- Populate the "years" table for y = 1, 88 do years[y] = startYear + y end -- Configure the picker wheel columns columnData = { -- Months { align = "center", width = 122, startIndex = dobMM, labels = { translations["January"][\_myG["language"]], translations["February"][\_myG["language"]], translations["March"][\_myG["language"]], translations["April"][\_myG["language"]], translations["May"][\_myG["language"]], translations["June"][\_myG["language"]], translations["July"][\_myG["language"]], translations["August"][\_myG["language"]], translations["September"][\_myG["language"]], translations["October"][\_myG["language"]], translations["November"][\_myG["language"]], translations["December"][\_myG["language"]] } }, -- Days { align = "center", width = 20, startIndex = dobDD, labels = days }, -- Years { align = "center", width = 80, startIndex = dobYYidx, labels = years } } if pickerWheel and pickerWheel.removeSelf then pickerWheel:removeSelf() pickerWheel = nil end -- Create the widget local pickerWheel = widget.newPickerWheel( { top = 120, left = 0, columns = columnData } ) pickerGroup:insert(pickerWheel)

For future readers, it appears that having the default anchors set in a separate Lua file caused the issue with my picker wheel. As I mentioned earlier, my picker wheel is shown early on when my users create accounts. On that same screen is a “Play Now” button where I let users play the game (in a scaled down form) without actually having to sign up for an account.

At the top of the “Play Now” game Lua, I had the anchor points defaults set as follows:

display.setDefault( "anchorX", 0 )  display.setDefault( "anchorY", 0 ) 

Once this code was executed and the user went back to the original sign up screen, then the picker wheel used these new default settings and jumped out of place. I simply removed these default settings and ensured that each display object had an explicit x/y anchor point specified thus resolving my issue.

Yes, that is global and once set affects EVERY object afterwards.  Corona is designed around 0.5, 0.5 so best work with that for minimal headaches.

Absolutely agreed on this point. The “default” anchor settings affect nearly everything , but not everything plays nicely with non-center anchors (widgets in particular). Typically, the default anchor points should be used like near the beginning of a process (a loop, a series of objects, etc.) which need to be anchored a certain way, and then immediately after you should reset the defaults to 0.5 so that other objects are not affected later.

I’ll add a warning to the documentation along these lines.

Brent

For future readers, it appears that having the default anchors set in a separate Lua file caused the issue with my picker wheel. As I mentioned earlier, my picker wheel is shown early on when my users create accounts. On that same screen is a “Play Now” button where I let users play the game (in a scaled down form) without actually having to sign up for an account.

At the top of the “Play Now” game Lua, I had the anchor points defaults set as follows:

display.setDefault( "anchorX", 0 )  display.setDefault( "anchorY", 0 ) 

Once this code was executed and the user went back to the original sign up screen, then the picker wheel used these new default settings and jumped out of place. I simply removed these default settings and ensured that each display object had an explicit x/y anchor point specified thus resolving my issue.

Yes, that is global and once set affects EVERY object afterwards.  Corona is designed around 0.5, 0.5 so best work with that for minimal headaches.

Absolutely agreed on this point. The “default” anchor settings affect nearly everything , but not everything plays nicely with non-center anchors (widgets in particular). Typically, the default anchor points should be used like near the beginning of a process (a loop, a series of objects, etc.) which need to be anchored a certain way, and then immediately after you should reset the defaults to 0.5 so that other objects are not affected later.

I’ll add a warning to the documentation along these lines.

Brent