Hi,
So I’m looping through a set of icon images and loading them up into a scrollview. As a part of the scrollview creation, I’m disabling vertical scroll on the scrollview. Once the scrollview is loaded up, I want to disable horizontal scrolling if the number of icons in the scrollview is <=7.
I try calling scroller.content.horizontalScrollDisabled = true
but it doesn’t work. Below is the function where I’m loading up the scrollview.
When I watch the Xcode console, I see this - Warning: Lua Runtime Error: lua_pcall failed with status: 2, error message is: ?:0: attempt to index field ‘content’ (a nil value)
I’m not sure what I’m doing wrong. Any help? Thanks.
function displayScroller()
print("scroller started")
native.setActivityIndicator(false)
local scroller = widget.newScrollView{
width = 1024,
height = 125,
scrollWidth = 1024,
scrollHeight = 125,
verticalScrollDisabled=true,
maskFile = "images/mask.png"
}
scroller.y=347
librarygroup:insert(scroller)
xFactor = 82
iconCount = 0
local iconImage
local doc\_dir = system.DocumentsDirectory
local doc\_path = system.pathForFile("stories", doc\_dir)
for file in lfs.dir(doc\_path) do
if string.len(file) == 4 then
fileName = file..".jpg"
iconImage = display.newImageRect("stories".."/"..file.."/"..file..".jpg", system.DocumentsDirectory , 125, 125 )
iconImage.x = xFactor
iconImage.y = 62
storytitle = file
xFactor = xFactor + 140
iconCount = iconCount + 1
scroller:insert( iconImage )
iconImage:addEventListener("tap",iconImageTap)
end
end
if iconCount \> 7 then
scroller.content.horizontalScrollDisabled = false
else
scroller.content.horizontalScrollDisabled = true
end
end
[import]uid: 141982 topic_id: 37272 reply_id: 67272[/import]