Disabling Horizontal Scroll in Scrollview

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]

Danny answered my question here -

http://developer.coronalabs.com/forum/2013/03/07/scrollview-widget-how-prevent-scrolling#comment-145510

Thanks Danny! [import]uid: 141982 topic_id: 37272 reply_id: 145511[/import]

Danny answered my question here -

http://developer.coronalabs.com/forum/2013/03/07/scrollview-widget-how-prevent-scrolling#comment-145510

Thanks Danny! [import]uid: 141982 topic_id: 37272 reply_id: 145511[/import]

Hi,

I am having the same problem, I want my scroll view to only scroll vertically and the following does not work;-
 

 --Create a scrollView scrollView = widget.newScrollView{ top = 57, left = 80, width = 228, height = 187, hideBackground = true, horizontalScrollDisabled = true, scrollWidth = 228, listener = scrollListener, maskFile = imgDir.."whitemask.png" }

I am using "

horizontalScrollDisabled

"

as shown in these docs;-

http://docs.coronalabs.com/daily/api/library/widget/newScrollView.html#horizontalscrolldisabled-optional

in amongst the references is introduced an ‘is’ to the front of the property, then elsewhere an underscore.

Can someone put this right as there is 3 different conflicting ways to refer to this property and none of them seem to work.

Thanks,

Jez

horizontalScrollDisabled = true is correct, and you should use the latest docs with the latest daily build as the ones online are out of date.

Thanks,

I have now downloaded the daily build.

I usually try and stick to “stable” builds as daily builds can introduce new bugs.

Now that we are using the daily build, I get an error on each place i use “scrolll:scrollToTop()”

“attempt to call method ‘scrollToTop’ (a nil value)”

Any idea how i can now fix this new bug we have created?

Its great to have resolved one issue but in a commercial setting, replacing it with another bug is fairly pointless.

Thanks anyway though.

Hi,

I am having the same problem, I want my scroll view to only scroll vertically and the following does not work;-
 

 --Create a scrollView scrollView = widget.newScrollView{ top = 57, left = 80, width = 228, height = 187, hideBackground = true, horizontalScrollDisabled = true, scrollWidth = 228, listener = scrollListener, maskFile = imgDir.."whitemask.png" }

I am using "

horizontalScrollDisabled

"

as shown in these docs;-

http://docs.coronalabs.com/daily/api/library/widget/newScrollView.html#horizontalscrolldisabled-optional

in amongst the references is introduced an ‘is’ to the front of the property, then elsewhere an underscore.

Can someone put this right as there is 3 different conflicting ways to refer to this property and none of them seem to work.

Thanks,

Jez

horizontalScrollDisabled = true is correct, and you should use the latest docs with the latest daily build as the ones online are out of date.

Thanks,

I have now downloaded the daily build.

I usually try and stick to “stable” builds as daily builds can introduce new bugs.

Now that we are using the daily build, I get an error on each place i use “scrolll:scrollToTop()”

“attempt to call method ‘scrollToTop’ (a nil value)”

Any idea how i can now fix this new bug we have created?

Its great to have resolved one issue but in a commercial setting, replacing it with another bug is fairly pointless.

Thanks anyway though.