Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift 3.0中点击弹幕报错 #56

Open
menicor opened this issue Apr 7, 2017 · 2 comments
Open

swift 3.0中点击弹幕报错 #56

menicor opened this issue Apr 7, 2017 · 2 comments

Comments

@menicor
Copy link

menicor commented Apr 7, 2017

func walkTextSpriteDescriptorWithDirection(direction:UInt) -> BarrageDescriptor{
let descriptor:BarrageDescriptor = BarrageDescriptor()
descriptor.spriteName = NSStringFromClass(BarrageWalkTextSprite.self)
descriptor.params["text"] = "过场文字弹幕"
descriptor.params["textColor"] = UIColor(red: CGFloat(arc4random()%255) / 255, green: CGFloat(arc4random()%255) / 255, blue: CGFloat(arc4random()%255) / 255, alpha: 1)
descriptor.params["speed"] = NSNumber.init(value: arc4random()%100 + 50)
descriptor.params["direction"] = NSNumber.init(value: direction)
descriptor.params["side"] = NSNumber.init(value: BarrageWalkSide.default.rawValue)
descriptor.params["clickAction"] = {
// let alertView = UIAlertView.init(title: "提示", message: "弹幕被点击", delegate: nil, cancelButtonTitle: "取消")
// alertView.show()
Log.shared.printLog("弹幕被点击")
}
return descriptor
}

这样为弹幕添加了一个点击事件,但是点击之后报错
报错信息

warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.

@LiMaoAtCD
Copy link

@menicor NSDictionary 不支持 value 为swift的闭包函数

@cornerAnt
Copy link
Contributor

cornerAnt commented Sep 24, 2017

@menicor �在�BarrageDescriptor类下修改代码
在.h增加方法

  • (void)clickAction:(BarrageClickAction)clickAction;

在.m实现方法

  • (void)clickAction:(BarrageClickAction)clickAction{

    self.params[@"clickAction"] = clickAction;

}
swift中使�用低的方法

    descriptor.clickAction { (params) in
       // Your Code
    }

如果不想修改源码,继承或者为BarrageDescriptor扩展这个方法也可以

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants