Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
How to remove UIView objects from screen? (WAX) — Gideros Forum

How to remove UIView objects from screen? (WAX)

ljp1203ljp1203 Member
edited January 2013 in General questions
Hi everyone!

I need some help with wax. I cant seem to find out how to remove a UIView object such as a datPicker for example from the screen. I've tried removeChild, removeFromParent. But I can't seem to figure out how to take it off the screen.

Help would be appreciated.

Thanks!
-Landon
JLS
Lead Coder and Designer
Tagged:

Comments

  • @Landon, UIKit objects are not Gideros Display objects and cannot be removed the same way as the Gideros Display objects.

    You need to remove the object from the superview.
    [datPicker removeFromSuperview];
    which will translate to
    datPicker:removeFromSuperview()
    you have skipped your reading the iOS manual/book ;) If you can, spend and buy the iOS tutorials from Ray Wanderlich, it is a good compilation and if you wnt to learn step-by-step then there are other books that take you slow.

    If you want to learn about pure Lua for iOS, there is also my book ( http://www.apress.com/9781430246626 )

    A little reading will definitely help.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • Update: You can read this one http://bit.ly/ZzbmN1 it is the UIView Documentation
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • @OZApps

    I tried what you just showed me, but it didn't work it keeps giving me an error.

    SCREENS/Party.lua:12: attempt to index global 'datePicker' (a nil value)
    stack traceback:
    SCREENS/Party.lua:12: in function

    Here is my code:
    Party = Core.class(Sprite)
    function Party:init()
     
    	--Create Event PlanitBtn	
    	local backBtn = Bitmap.new(Texture.new("Images/backbtn.png"))
    	local backBtn_over = Bitmap.new(Texture.new("Images/backbtn_over.png"))
     
    	--The Actual PlanitBtn and Listener
    	local backbtn = PlanitBtn.new(backBtn, backBtn_over)
    	backbtn:addEventListener("click",
    		function()
    			datePicker:removeFromSuperview()
    		end)		
     
    	--Add PlanitBtn To Scene
    	backbtn:setPosition(35,70)
    	self:addChild(backbtn)
    	---------------------------------------------------------------------------------------------------------------
    	--Sign Up PlanitBtn	
    	local signupBtn = Bitmap.new(Texture.new("Images/signupbtn.png"))
    	local signupBtn_over = Bitmap.new(Texture.new("Images/signupbtn_over.png"))
     
    	--The Actual PlanitBtn and Listener
    	local button2 = PlanitBtn.new(signupBtn, signupBtn_over)
    	button2:addEventListener("click",
    		function()
    			local datePicker = UIDatePicker:init()
    			getRootViewController():view():addSubview(datePicker)
    			local dateFrame = BhUIViewFrame.new(datePicker, CGRect(0,264,0,0))
    			self:addChild(dateFrame)
    		end)
     
    	--Add PlanitBtn To Scene
    	button2:setPosition(320, 370)
    	self:addChild(button2)
     
     
     
    end
    I have all the files necessary for Wax. Hopefully you can help with this :)

    Thanks.
    -Landon
    JLS
    Lead Coder and Designer
  • Is datePicker available ? is it a global variable that can be accessed by this lua file/module?

    In all of your previous dicussion you have called it datPicker and now you are calling it datePicker.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • @OZApps

    I ment to say datePicker if I spelt it wrong. And what do you mean by being available?
    Does it have to be in it's own lua file?

    Thanks
    JLS
    Lead Coder and Designer
  • by available I mean can it be accessed from another lua file? The scope, is it Global, because if you have

    -- file1.lua
    local myvar
    myvar = "show me"

    -- file2.lua
    print(myvar)

    it will print nil as myvar is not accessable from file2, so either make it global by removing the local before the myvar or pass it as a parameter to file2 and save it somewhere in that scope.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • @OZApps

    Thanks for telling me that. I removed local in front of it, and it worked. Thanks.

    Also, you may have answered this before for me, but I want to close the keyboard by clicking done on the keyboard when a UITextField is invoked. I found this code:

    - (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return NO;
    }

    But when I try to convert it into LUA, it gives me all sorts of errors. How would I convert this type of code?

    Thanks.
    JLS
    Lead Coder and Designer
Sign In or Register to comment.