【发布时间】:2015-03-26 00:43:20
【问题描述】:
编辑:
- 在 iOS 8.1 的 iPad Mini 上运行
- 我尝试了一个测试项目以在应用程序中挂钩
viewDidLoad以显示 UIAlertView,但没有任何反应。有谁知道什么可能导致调整编译但无法正常运行?
10 小时的调试,我正在转向 SO。
这段代码显然有问题,我不知道是什么原因造成的。我在 ChineseSkill 应用程序中连接了 TestOut 视图,但是当我进入该视图时,它的行为就好像与原始应用程序没有任何变化一样。
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TestOutViewController : UIViewController <UIAlertViewDelegate>
- (UIButton *)quitButton;
@end
%hook TestOutViewController
- (void)viewDidAppear:(BOOL)view {
%orig;
UIButton *infiniteLivesButton = [UIButton buttonWithType:UIButtonTypeSystem];
[infiniteLivesButton setTitle:@"Infinite Lives" forState:UIControlStateNormal];
[infiniteLivesButton setFrame:CGRectMake(/*[self quitButton].frame.origin.x + [self quitButton].frame.size.width, [self quitButton].frame.origin.y + 20*/50, 50, 200, 50)];
[infiniteLivesButton setBackgroundColor:[UIColor redColor]];
[infiniteLivesButton addTarget:self
action:@selector(makeLivesInfinite:)
forControlEvents:UIControlEventTouchUpInside];
UIButton *passTestButton = [UIButton buttonWithType:UIButtonTypeSystem];
[passTestButton setTitle:@"Skip Test" forState:UIControlStateNormal];
[passTestButton setFrame:CGRectMake(infiniteLivesButton.frame.origin.x + infiniteLivesButton.frame.size.width + 10,
infiniteLivesButton.frame.origin.y,
150,
50)];
[passTestButton addTarget:self
action:@selector(skipTest:)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:passTestButton];
[self.view addSubview:infiniteLivesButton];
UIAlertView *successAlertView = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Infinite hearts for the rest of this test." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[successAlertView show];
}
- (void)touchesBegan:(id)began withEvent:(id)event {
UIAlertView *testView = [[UIAlertView alloc] initWithTitle:@"Test" message:@"Test Alert" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[testView show];
}
%new
- (void)makeLivesInfinite:(UIButton *)sender {
[self performSelector:@selector(setNNumberofLeftHearts:) withObject:@1000000];
UIAlertView *successAlertView = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Infinite hearts for the rest of this test." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[successAlertView show];
}
%new
- (UIButton *)quitButton {
return objc_getAssociatedObject(self, @selector(quitButton));
}
%new
- (void)skipTest:(UIButton *)sender {
[self performSelector:@selector(setNTotalTest:) withObject:@1];
[self performSelector:@selector(CheckOrContinueButtonClick:) withObject:NULL];
[self performSelector:@selector(CheckOrContinueButtonClick:) withObject:NULL];
}
%end
没有警报视图,没有添加的视图,什么都没有。几乎任何事情都会有所帮助。
【问题讨论】:
-
什么是TestOutViewController,是什么让你认为它存在?
-
是一个VC,负责在app里测试。我很确定它存在(但我可能是错的,所以请纠正我)因为在未加密的应用程序上使用 class-dump-z 后,它是生成的头文件之一。 pastebin.com/qSebYz9T
-
只是为了确保您正确设置过滤器(在您的调整 plist 文件中)?
-
我没有改变任何东西。 应该是什么样的?
-
plist 应该设置为您的应用程序,而不是 SpringBoard
标签: objective-c jailbreak theos