我的代码有什么问题??我对整个越狱开发过程有些陌生。如果有人可以帮助我解决这个问题。我试图对我学到的新东西进行测试,并且我试图在主屏幕上显示一个 UIButton 来创建一个 UIAlertView。
%hook SBUIController
- (void)finishLaunching
{
UIButton *myButton;
myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(25, 85, 100, 35);
[myButton setTitle:@"Test" forState: UIControlStateNormal];
[myButton addTarget:self action:@selector(myButtonPressed) forControlEvents:UIControlEventTouchUpInside];
SBUIController *ui = MSHookIvar<id>(self, "_uiController");
[[ui window] addSubview:myButton];
}
%new(v@:)
-(void)myButtonPressed{
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"Title of Alert" message:@"Message of Alert" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
}
%end