我想创建一个全局工具提示样式的类,根据上下文有不同的操作,如何将事件处理程序块放在特定的操作上,如tap?例如:
MyClass *toolTip = [MyClass new];
toolTip.text = @"Here is a tip, click here to do something";
toolTip.tapHandler = ^{
//Custom actions here
}
答案 0 :(得分:1)
猜猜你想要定义块的处理程序属性。您可以定义这样的属性。
onMeasure()
或者,您可以使用typedef使其更清晰。
@interface MyClass : NSObject
@property (strong, nonatomic) void (^tapHander)(void);
@end