TableViews, ScrollViews and Imagesheets Bug

Yesterday I filed a bug report ( #15773 ) about this issue I was having on build 840, when I tried to put an Imagesheet derived sprite into a tableView.

In my report, I suggested that it just wasn’t possible to do if you had a masked tableview, however, today, after playing around with it, and talking to a few people on the IRC, I’ve found out more about the nature of the problem and the (temporary, I hope) fix.

The issue is not that you cannot put Imagesheet derived display objects into the tableView, the issue is actually that they cannot be the lowest level item in the view hierarchy.

This problem is not limited to just tableViews, but also applies to scrollViews, if they have been masked. Furthermore, it is not limited to Sprites but also ImageRects produced from Imagesheets (and I assume Images, although I have not tested that).

My fix, then, is to insert a 1x1 rectangle below the Imagesheet derived display object, (and under it so it is not visible) which seems to work. I have tried setting .isVisible on the rectangle to false, and also settings its alpha component to anything but 100%, and these both break the fix.

Here’s an illustrated example:

If I use this code in my onRender listener of the row:

[lua]function( e )

local group = e.view

–local bugFix = display.newRect( group,
– 20, 20,
– 1, 1 )

local greenSqrBtnSht = cache:fetch( “img/greenSqrButton.png” )
local newGameBtn = buttons.newButton( greenSqrBtnSht,
“new game”, c.BTN_FNT_MED, c.BTN_DEF_FNT_FAM,
tableView, “newGameButtonPressed” )

tableView.newGameBtn = newGameBtn

newGameBtn:setReferencePoint( display.CenterReferencePoint )
–bugFix:setReferencePoint( display.CenterReferencePoint )

group:insert( newGameBtn )

newGameBtn.x = group.width / 2
newGameBtn.y = group.height / 2

–bugFix.x = group.width / 2
–bugFix.y = group.height / 2

end,[/lua]

Then I get the following in my scene:
Screenshot with bug

however, with the comments in the above code uncommented (the rectangle added first), I get this:
Screenshot without bug

Some notes on my code:

cache:fetch( ... ) returns an Imagesheet

buttons.newButton( ... ) returns a display group with an Imagesheet derived Sprite as the bottom-most element (and two text display objects above it)

c. All values in this namespace are constants (like #define values)

tableView This code is in the scope where I created the tableView instance it belongs to.

So if anybody else is having this problem, it would be great if you could share your experiences in this thread. As I said, I submitted a bug report ( #15773 ), but since then, I discovered more about the problem, so I decided to make this thread.

Thanks,
Ashok [import]uid: 56979 topic_id: 28755 reply_id: 328755[/import]

I had similar problem with scrollview. I had there many rows. Each row is an image, a text and a button, which is a new api sprite.
So the problem was that only first row showed up. Consequent rows only showed text and buttons. Images were missing.

So only the first inserted image showed up.

Solved by reordering scrollview:insert() statements. [import]uid: 58303 topic_id: 28755 reply_id: 115918[/import]