Hi all!
I need some help with implementing Wax into my app.
I followed
@bowerandy video tutorial video exactly. But every time I try to run my GiderosIOSPlayer, it says I have a sematic issue and it won't let me run and it says build failed. I've attached a screenshot of what is happening and hopefully you can help me!
Thanks!
-Landon
Comments
Best regards
I started again from scratch and still got the same problem. What header files would I be missing?
Thanks!
-Landon
Lead Coder and Designer
Don't get me wrong, in most cases I'm happy to help out but you don't seem to be willing to put in any effort to help me (or anyone else) help you.
Look at it like this. What do you expect me to do? I could record another, more detailed, video or I could write down step by step the process of building the plugin. Each of these would take at least an hour of my time and there would still be no guarantee of success.
Have you thought about what you could do to make it easier for people to help you? Perhaps you could record a video of what you are doing and post that up so we can see where the problem is? Perhaps you could upload your XCode project to Dropbox so I can look at it? You could even start by saying what version of Gideros you are using or what version of Xcode?
Sorry for the rant - maybe I've had a bad day
Best regards
We use this for ourselves and therefore know it works.
https://www.dropbox.com/s/ez48j1uy5mgvvl5/GiderosiOSPlayer.zip
Hope this helps
If your problem persists maybe it is a problem with the version of xCode you are using, try making sure you have the latest version.
@bowerandy and @atilim hope you don't mind me sending this as it contains both the Gideros iOS Player code by atilim and the wax plugin by bowerandy.
I now I just have one more question, how do I add a status bar to my app?
I used:
main.lua:1: attempt to index global 'UIApplication' (a nil value)
stack traceback:
main.lua:1: in main chunk
If it helps, I am using SceneManager.
Thanks!
-Landon
Lead Coder and Designer
https://www.dropbox.com/s/jbrseuj6ldgngos/Wax.zip
Then add require "wax" to the top of your main.lua file
That should fix it
@gorkem thanks, I'm not sure how haha but if I do I'd be glad to invest.
BTW, I guess that Xcode project that @SimpleLoop sent you fixed the problem? Did you look back and find out what the issue was? Otherwise you are going to have the same difficulty when you try and export your own Gideros projects and deploy them.
From reading your error message it looks like since it is saying that wax_setCurrentLuaState() is undeclared it appears that the original wax.m or .h file from the Corey Johnson wax project is not in your project.
If you could make sure all the files that are in our Gideros iOS Players plugins/wax folder in xCode are in your project. As I think it may just be down to a missing file.
best regards
Removed the old hotwax plugin from my Gideros iOS Player and added the new static library and Linker Flag in under 10 seconds and it appears to work perfectly.
Thank you so much for making it a static library was so much easier than finding all the bits and putting them in the right place.
One quick question, you don't happen to know how to do UIAnimations using it do you?
I have this function run by a button:
function ioButtonAction(self, sender)
frame = self.imageViewToAnimate:frame()
frame.y = 0
self:view():beginAnimations(nil):context(nil)
self:view():setAnimationDuration(1000)
self:view():setAnimationDelay(0)
self:view():setAnimationCurve(UIViewAnimationCurveLinear)
self.imageViewToAnimate:setFrame(frame)
self:view():commitAnimations()
end
but keep getting this error in the xCode debugger:
attempt to call method 'beginAnimations' (a nil value)
Obviously it can't find the method beginAnimations on the view self:view().
but as far as I can tell the function is correct as in xCode it looks like this and works without issue:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
[UIView setAnimationDelay:delay];
[UIView setAnimationCurve:animCurve];
imageViewToAnimate.frame = frame;
[UIView commitAnimations];
although in xCode it is UIView not an actual view but when I tried that in place of self:view() it said attempt to call global 'UIView' (a userdata value).
Any help appreciated as always.
I haven't tried UIAnimations but based on the code you have at the bottom, shouldn't it be:
UIView:beginAnimations_context(nil, nil)
The line [UIView beginAnimations:nil context:nil] is a single message send. You can tell because it is between a single set of square braces. The message selector is beginAnimations:context:, which maps to beginAnimations_context() in the wax world.
BTW, just in case you are playing with UIAnimations because you haven't seen it, you can also do animations with UIView controls that are compatible with the rest of Gideros by wrapping your controls in a BhUIViewFrame. Check out the BhWaxPhysicDemo files for an example. Here's the video:
best regards
Dislikes: bgcis
I have yet another question
How could I add a tab bar at the bottom of the application to allow me switch between different views?
Thanks!
Lead Coder and Designer
UIView:beginAnimations_context(nil, nil)
UIView:setAnimationDuration(1000)
UIView:setAnimationDelay(0)
UIView:setAnimationCurve(UIViewAnimationCurveLinear)
imageViewToAnimate:setFrame(frame)
UIView:commitAnimations()
doesn't throw any errors but also doesn't seem to animate but if I go to another view then back to that one it appears to be in the new position.
So it appears that the UIView:commitAnimations() is not working.
I'll keep fiddling and say if I get it working.
Thanks for all your help.
@ljp1203 you should be able to create a UITabBarController and add it to the main view then create two UIView controllers and add them to it.
To create the tab bar it would be something like.
tabBarController = UITabBarController:init()
tabBarController :setFrame(CGRect(0, 0, 320, 460))
tabBarController:setViewControllers(array of controllers)
self:view():addSubview(tabBarController:view())
Hope this helps.
The code works perfectly now.
The problem was that xCode does the duration in seconds rather than miliseconds so I was setting the duration to 1000 seconds therefore did not notice that it was actually doing it. After changing it to 1 second it works perfectly.
Thanks for all your help with this.
I'm glad you've sorted the problem and got it working.
One thing though. You seem to have a bit of confusion over when to use :view() and when to use UIView itself. You may have worked this out but the thing to realize is that UIView is a class object and self:view() returns an instance of that class.
In ObjectiveC classes are also objects. So if I do:
local tvClass=UITextView
local tvInstance=UITextView:initWithFrame(CGREct(blah, blah))
Then tvClass is holding a pointer to the UITextView class object and tvInstance is hold the pointer to the UITextView object (the actual text view) itself. Most of the time you only deal with class objects when you want to create new instances of the class. All the initXXX methods in Wax are *class methods* because you action them off a class object. Sometimes class objects are called "factory objects" because they are used to build instances (like a factory).
Once you have an instance object (tvInstance in the above) then you can call instance methods on it. In the IOS documentation, e.g. for UIView you can see which methods are class methods because they are marked with a "+". Instance methods are marked with a "-". So look in the docs for UIView and find the Animating Views section and you'll see that all those animation methods are class (+) methods. This means they must go to UIView itself (the class object). That's why you do:
UIView:beginAnimations_context(nil, nil)
rather than:
self:view():UIView:beginAnimations_context(nil, nil)
But @bowerandy, you say. How come I call initWithFrame: as if it is a class method? It's marked with a "-" in the docs. This is an exception because of the way Wax works. There are no calls to "alloc" in Wax because all the memory management is done for you. For this reason Corey Johnson (the inventor of Wax) chose to make all the initXXX instance methods *appear* as if they are class methods. It's confusing but once you get used to itit, it all makes sense.
I'm sorry if you knew all this already; I just thought I'd try to clarify in case you didn't.
best regards
PS: At some point, if you are curious, you are going to ask yourself, "if all class objects are objects themselves and all objects have classes, them what is the class of a class object?". I warn you now, that way madness lies. You will need to bind your head with a strap to keep your brain in if you try to understand it all.
I have yet another question
How do I add native textfields to allow users to add info into them?
Thanks!
-Landon
Lead Coder and Designer
I downloaded your sample project from https://github.com/bowerhaus/BhWax
And whenever I would try to run it, it would give me errors saying that .lua files didn't exist and also other wax realted issues.
Thanks!
-Landon
Lead Coder and Designer
You will need to make your view a UITextField Delegate
To do this I have a separate lua file called mainView.lua
Into this file I put
-- This makes it into a UIViewController and UITextFieldDelegate
waxClass{"mainView", UIViewController, protocols = {"UITextFieldDelegate"}}
-- Init the View
function init(self)
self.super:init()
return self
end
-- When the view loads add the stuff to it
function viewDidLoad(self)
-- Add a textField
self.mainTxt = UITextField:initWithFrame(CGRect(30,30,260,80))
-- set the delegate
self.mainTxt:setDelegate(self)
-- Set Border Style
self.mainTxt:setBorderStyle(UITextBorderStyleRoundedRect)
-- Set Placeholder text
self.mainTxt:setPlaceholder("Main Text")
-- Set Text Alignment
self.mainTxt:setTextAlignment(UITextAlignmentCenter)
-- Add to view
self:view():addSubview(self.mainTxt)
end
----- Text Field Delegate Functions -----
function textFieldShouldBeginEditing(self, textField)
print("textFieldShouldBeginEditing")
return true
end
function textFieldDidBeginEditing(self, textField)
end
function textFieldShouldEndEditing(self, textField)
print("textFieldShouldEndEditing")
return true
end
function textFieldDidEndEditing(self, textField)
print("textFieldDidEndEditing")
end
function textFieldShouldReturn(self, textField)
print("textFieldShouldReturn")
textField:resignFirstResponder()
return true
end
Then in my main.lua I put
local mainView = mainView
getRootViewController():view():addSubview(mainView:view())
Any problems happy to help.
For the BhWax library I believe you will also require the Misc, Gideros, CoreytJohnsonWax and BhHelpers repositories on your machine. You need to make sure they go in the right directories as specified in the READMEs.
best regards
Thanks for the responses.
@SimpleLoop , where could I find all of the code for things such as textfields and other native things like the code you keep giving me? Such as an API sheet.
@bowerandy , thanks, it now works!
Lead Coder and Designer
I need some help with the UIKIT Plugin.
I am also using SceneManager by @ar2rsawseen .
Now the issue I am getting is that every time I click on the button it doesn't change scenes at all, and I can't seem to figure out why. There are no errors whenever I run it on my iPhone.
Here is my code:
-Landon
Lead Coder and Designer