alibaba/wax

lua中运行block崩溃

lutetium71 opened this issue · 0 comments

你好,block使用中有个问题,直接贴代码吧。

waxClass{"MenuDetailController", UIViewController}

function viewDidLoad( self )
    self:setTitle("Menu Detail")
    self:view():setBackgroundColor(UIColor:whiteColor())

    local label = UILabel:initWithFrame(CGRect(20, 84, 300, 60))
    self.label = label
    label:setBackgroundColor(UIColor: cyanColor())
    label:setText("Menu Detail")
    label:setFont(UIFont:boldSystemFontOfSize(36))
    self:view():addSubview(label)

    -- self:updateConstraints(self);

    UIView:animateWithDuration_animations_completion(1, 
        toblock(
            function()
                -- self.label:setCenter(CGPoint(200, 200))
                print("in block")
            end
        ),
        toblock(
                function(finished)
                    print('lua animations completion ' .. tostring(finished))
                end
        ,{"void", "BOOL"})-- return void
    )
end

运行后崩溃,错误提示如下:

1: (string) 'MenuDetailController.lua:17: attempt to call global 'toblock' (a nil value)'

Lua panicked and quit: Error calling 'viewDidLoad' on '<MenuDetailController: 0x7fa6d2934a60>'
MenuDetailController.lua:17: attempt to call global 'toblock' (a nil value)
stack traceback:
    [C]: in function 'toblock'
    MenuDetailController.lua:17: in function <MenuDetailController.lua:3>

代码里的block调用是按照示例来写的,有空请帮忙看看,谢谢