newTableView:scrollToY not working on IOS

Hi,

We have the following problem and we do not understand why it is not working. Here is what we try to accomplish

First step :

  1. create a newTableView widget
  2. populate it (about 50 items, no cat)
  3. save the last position using getContentPosition() before closing the view

Second step:

  1. create a newTableView widget
  2. populate it with the same items as before
  3. set the Y previously saved position using scrollToY with a time of 0 (zero) and it does not work. 

If we set a time other than 0 (zero) then it will work. But for us, when we show back a list we don’t want an animation of a list scrolling from the beginning to the desired location. It does not make sense. We want the list to open to our desire location instantaneously.

Is this a bug? have others encounter this ? Is there a workaround ?

thanks for your help

Hi @nmichaud,

Which build # is this occurring in? It may be a bug, since the docs state that a time of 0 should be an instantaneous effect (no transition).

Brent

Hi #Brent,

This is occurring in the build 2014.2179. It was not working on build 2014.2156 either, this is why we try the latest one and still no luck.

I recall this bug from way back but I thought it had been fixed. Seems like its coming back. Good catch. 

@Brent, any news on this one ?

Have you tried setting it to just 1? I think maybe should be just as fast as a temporary fix…

I’ve reported this for testing and a fix as of yesterday, Feb. 17, 2014.

Thanks,

Brent

@eja, we are doing the time to 1 for the time being, but it create and horrible flickering which is quite unacceptable for a tourism app like ours.

@brent, do you have a timeframe for this fix to be available in an upcoming daily build ?

Yes, this should be fixed in an upcoming daily.

Brent

@Brent, sorry to push for this. But do you have an ETA on this one. This is our last showstopper preventing us from being code complete.

@nmichaud,

I believe this one is in final testing. I’ll see if I can push it through this week…

Brent

@Brent, The fix is not in the next Public Release Candidate (2014.2187). Is this normal ?

@nmichaud: It is normal. Some fixes come in after the first release candidate.

Looking at this, i really can’t replicate it properly. Here is the code i use, based on your description:

-- Import the widget library local widget = require( "widget" ) local list, widgetGroup widgetGroup = display.newGroup() local function drawTable() -- create a constant for the left spacing of the row content local LEFT\_PADDING = 10 -- Handle row rendering local function onRowRender( event ) local phase = event.phase local row = event.row local groupContentHeight = row.contentHeight local rowTitle = display.newText( row, "List item " .. row.index, 0, 0, native.systemFontBold, 16 ) -- in Graphics 2.0, the row.x is the center of the row, no longer the top left. rowTitle.x = LEFT\_PADDING -- we also set the anchorX of the text to 0, so the object is x-anchored at the left rowTitle.anchorX = 0 rowTitle.y = groupContentHeight \* 0.5 rowTitle:setFillColor( 0, 0, 0 ) end -- Create a tableView list = widget.newTableView { top = 38, width = 320, height = 448, onRowRender = onRowRender, } --Insert widgets/images into a group widgetGroup:insert( list ) -- insert rows into list (tableView widget) for i = 1, 30 do list:insertRow{ height = 72, } end end drawTable() local function redrawTable() -- save position local pos = list:getContentPosition() print( " got position: ", pos ) -- remove the list list:removeSelf() -- redraw it drawTable() -- scroll into it with time 0 list:scrollToY( { y = pos, time = 0, onComplete = function() print( " new position: ", list:getContentPosition() ) end } ) end -- redraw the table after 1sec timer.performWithDelay( 1000, redrawTable ) 

Did i capture all the data you provided correctly? Could you run this for me and see if it works properly on your project setup? Furthermore, if this works and your code does not, could you provide a minimal bug report ( main.lua + config files ) and paste its number back in here?

Thanks,

alex

One more thing if not clear. The getContentPosition() method does not return the actual y of the last row added. But the yPosition of the tableView’s view. So in order to have getContentPosition() returning the y of the last row added in the tableview, you would have to scroll the tableview all the way to the last row. The testbed i provided works with the assumption that within the 1000msec delay before refreshing the list, you scroll it, and after recreating it, its position will be set to the coordinate you scrolled at.

Thanks,

alex

hey Alex, is there a reason why when i use scrollToY while the view is scrolling (via momentum) it will shift to the top but continue moving… scrollView’s scrollToPosition does not do this…

Hey eja,

I actually noticed that while looking at another bug report. The fix should come up in a daily soon.

alex

@alexf We will try it and get back to you quickly

@alexf You are right, we try the code and it is working perfectly. We will investigate more why we do not have the same behavior in our app.

Hi @nmichaud,

Which build # is this occurring in? It may be a bug, since the docs state that a time of 0 should be an instantaneous effect (no transition).

Brent

Hi #Brent,

This is occurring in the build 2014.2179. It was not working on build 2014.2156 either, this is why we try the latest one and still no luck.