how to add property for waxClass

100 views
Skip to first unread message

Dave Wang

unread,
Feb 28, 2013, 9:55:47 PM2/28/13
to ipho...@googlegroups.com
Hello ,how are you,I use  wax get error.then i add property(user data).
eq.

waxClass{"AutoSizeButton", UIControl}

function initWithFrame(self,frame)
    self.super:initWithFrame(frame)

    local label_ =  UILabel:initWithFrame(frame)
    label_:setTextColor(UIColor:whiteColor());
    label_:setBackgroundColor (UIColor:clearColor());
    label_:setTextAlignment ( UITextAlignmentCenter);
    label_:setFont (UIFont:boldSystemFontOfSize(NavBar_Font_SIZE));
    label_:setShadowColor (UIColor:blackColor());
    label_:setShadowOffset (CGSize(-1, -1));
    label_:setHighlighted(YES);
    label_:setHighlightedTextColor(UIColor:whiteColor());
    puts("===="..label_);
    self:addSubView(label_);
    self:setBackgroundColor(UIColor:clearColor());
    self:setHighlighted(YES);
    self:setOpaque(NO);

end



then run to  local label_ =  UILabel:initWithFrame(frame) is error " attempt to concatenate local 'label_' (a userdata value)",what to do fix this. 

Looking forward to your reply. Thanks!

Benjamin Tolputt

unread,
Feb 28, 2013, 10:00:04 PM2/28/13
to ipho...@googlegroups.com
On 01/03/2013, at 1:55 PM, Dave Wang wrote:

waxClass{"AutoSizeButton", UIControl}

function initWithFrame(self,frame)
    self.super:initWithFrame(frame)

    local label_ =  UILabel:initWithFrame(frame)
    ...
    puts("===="..label_);

end

then run to  local label_ =  UILabel:initWithFrame(frame) is error " attempt to concatenate local 'label_' (a userdata value)",what to do fix this. 

You should wrap the user data in a tostring(..) call as follows:

  local label_ = UILabel:initWithFrame(frame)
  puts("--> "..tostring(label_))

--
Benjamin Tolputt

Dave Wang

unread,
Feb 28, 2013, 11:36:21 PM2/28/13
to ipho...@googlegroups.com
Think!Is ok!

在 2013年3月1日星期五UTC+8上午11时00分04秒,B.J.Tolputt写道:

Amor Yin

unread,
Apr 1, 2016, 9:14:32 AM4/1/16
to iPhone Wax
u can do this:

if self.label_ == nil then
   
local label_ = UILabel:initWithframe(rect)
   
self.label_ = label_
end



在 2013年3月1日星期五 UTC+8下午12:36:21,Dave Wang写道:
Reply all
Reply to author
Forward
0 new messages