我的调整没有执行

时间:2015-03-26 00:43:21

标签: objective-c jailbreak theos

编辑:

  • 在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

没有警报视图,没有添加视图,没有任何内容。几乎任何事情都会有所帮助。

1 个答案:

答案 0 :(得分:1)

您的问题是您必须在tweak的plist文件中设置正确的过滤器。默认情况下,plist文件具有包标识符过滤器com.apple.springboard。您应该将其更改为您希望代码注入的应用程序的包标识符。

更多信息(稍等):

背后发生了什么? MobileLoader负责将代码修补到程序中。这些plist文件告诉MobileLoader修补程序中的代码,在哪个框架或哪个框架中运行。因此,您的流程是应用而不是SpringBoard。这link 对CydiaSubstrate(MobileSubstrate)有很好的解释。您还可以查看其文档。