Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How do I delete objects from a ScrollView?
Started by michaeldunn92001 Nov 18 2017 06:37 AM

No replies to this topic
scrollview objects removal of objects
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

michaeldunn92001

[GLOBAL: userInfoPane.html]
michaeldunn92001
  • Observer

  • 4 posts
  • Corona SDK

Hi, I am trying to remove text objects from a scrollView (to simulate going through a place selector where you can choose your state > county > and then school, but when I try to delete objects they don't remove themselves.
 
I've tried object:removeSelf(); object = ni
 
I've also tried display.remove(object)
 
And I've also tried removing them from the scrollView
 
But, none of these options worked and I'm a bit puzzled. :huh:
 
 
Here's a portion of the code. It is running in a module to save space in my main files. Corona version is on 2017.3178, but it functions the same on previous versions.


local scrollViewCreator = {}
local widget = require("widget")
local storage = require("storage")

local AllSchoolsTable = {}

local SchoolsButtons = {}


local scrollView

function scrollViewCreator.createScrollView(catagory, parameter, ratio) -- Return Table of All Schools
	
	
	if (scrollView ~= nil) then


		
		for i = 1,#SchoolsButtons do -- Remove buttons
			print("Removing")
			scrollView:remove(SchoolsButtons[i])
			SchoolsButtons[i]:removeSelf()
			SchoolsButtons[i] = nil
		end

		
		SchoolsButtons = {}

	end
	
	if (textGroup == nil) then
		textGroup = display.newGroup()
	end
	
	if (scrollView == nil) then
		scrollView = widget.newScrollView({x = display.contentCenterX,y = display.contentCenterY,width = display.contentWidth, height = display.contentHeight/2,horizontalScrollDisabled = true, hideBackground = false, backgroundColor = {3/255, 166/255, 120/255}})
	end
	
	
	AllSchoolsTable = storage.GetAll(catagory, parameter) -- Returns values to use with the text objects
	
	for i =  1,#AllSchoolsTable do -- Creates text buttons and inserts them into the ScrolLView
	
		SchoolsButtons[i] = display.newText({parent = textGroup, text = AllSchoolsTable[i], x = display.contentCenterX, y = (120 * i) * ratio, font = mainFont,fontSize = 60 * ratio,align = "center"})
		SchoolsButtons[i].name = AllSchoolsTable[i]
		
		scrollView:insert(SchoolsButtons[i])
		
	end

   -- adds listeners down here.
end

Any help would be appreciated, this issue has perplexed me. 




[topic_controls]
[/topic_controls]