嗯,我不能得到这个工作。我的目标是将UIButton添加到Minecraft Pocket Edition中。我认为这个问题很容易或很明显,所以请不要因为一小段代码而陷入困境。
非常感谢, Kivifreak
#import <substrate.h>
#import <UIKit/UIKit.h>
@interface Tpschanger
UIButton *myButton;
UIView *myView;
-(void) TPSButton;
@end
%hook minecraftpeViewController
-(void)viewDidLoad {
myView=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,480)];
myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(20, 20, 200, 44);
[myButton setTitle:@"TPS" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(TPSButton:) forControlEvents:UIControlStateNormal];
[self.myView addSubview:myButton];
> I get an error at the previous line: request for member ‘myView’ in ‘self’, which is of non-class type ‘minecraftpeViewController*’
%orig;
}
%new
-(void) TPSButton {
}
%end
答案 0 :(得分:0)
应该是[self.view addSubview:myButton];
IMO,你不需要myView。