I define a button,and set button‘s property selected is false,as a result, it is crashed,How can I do ? below is code:
function setupButton(self)
local bt = UIButton:initWithFrame(CGRect(200,100,100,30))
self:view():addSubview(bt)
bt:setSelected(false)
print(bt:selected())-- causes Runtime error: attempt to call method 'selected' (a nil value)
end
it means there is no method 'selected' in UIButton.
see the definition: @property(nonatomic,getter=isSelected) BOOL selected;
so, you should use print(bt:isSelected())
I define a button,and set button‘s property selected is false,as a result, it is crashed,How can I do ? below is code:
function setupButton(self) local bt = UIButton:initWithFrame(CGRect(200,100,100,30)) self:view():addSubview(bt) bt:setSelected(false) print(bt:selected())-- causes Runtime error: attempt to call method 'selected' (a nil value) end