注:此代码是不是原始代码的翻版,但足以说明(具有良好的精度)是什么问题,我的代码的意图是什么。调用从另一个类的功能与标志(%钩)
我添加了一个按钮,DaClass1
的看法(这工作得很好):
%hook DaClass1
-(id)DaView {
UIButton *xButton = [UIButton buttonWithType:UIButtonTypeCustom];
[xButton addTarget:self action:@selector(dismissWithAnimation:YES:nil)
forControlEvents:UIControlEventTouchUpInside];
[xButton setBackgroundImage:[UIImage imageWithContentsOfFile:@"/Hello.png"] forState:UIControlStateNormal];
xButton.frame = CGRectMake(0, 0, 30, 30);
[self addSubview:xButton];
return %orig;
}
%end
但UIButton
的action:
(dismissWithAnimation:YES:nil
)实际上是从另一个类:
%hook DaClass2
-(void)dismissWithAnimation:(int) reason:(int) {
//someCodeHere...
}
%end
我怎么可以叫dismissWithAnimation
在DaClass2
从我UIButton
的action:
当UIButton的是DaClass1
?
它是DaClass2的一个实例,除非它是一个类的方法。 – HackyStack 2013-03-08 21:45:06
还是坚持DaClass2的一个实例的引用,声明局部按钮按下处理方法,在这种方法中,调用DaClass2对象的dismissWithAnimation方法。 – HackyStack 2013-03-08 21:48:22