【问题标题】:Why does my Tweak Not work Correctly?为什么我的 Tweak 不能正常工作?
【发布时间】:2014-02-02 14:27:10
【问题描述】:

我正在为运行 IOS 7 的 iPhone 进行我的第一个 MobileSubstrate 调整。

我正在使用this tutorial

本教程解释了Hooking 的基础知识,并提供了他的源代码的 git hub 示例。

为了测试他编写的代码是否有效并让我了解 theos 编译终端,我编译了他的项目。

该项目假设在启动应用程序时显示UIAlert,并在iPhone的设置应用程序中放置一个设置开关,状态为开或关。

在我的 iphone 上安装这个编译的 deb 时,添加了设置页面,因此我可以打开或关闭该功能,但是当该功能打开时,警报不会显示。

这是我的 Tweak.xm 代码:​​

@interface SBApplicationIcon
-(void)launch;
-(id)displayName;
@end

%hook SBApplicationIcon
-(void)launch
{
    NSString *appName = [self displayName];

    NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithContentsOfFile:
                                    [NSString stringWithFormat:@"%@/Library/Preferences/%@", NSHomeDirectory(), @"com.AndyIbanez.NotifierSettings.plist"]];
    NSNumber* shouldNotify = [settings objectForKey:@"alertLaunch"];

    if([shouldNotify boolValue] == YES)
    {
        NSString *message = [NSString stringWithFormat:@"The app %@ has been launched", appName, nil];
        UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:appName message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert1 show];
        [alert1 release];
    }
    %orig;
}
%end

这是我关注且引人注目的 GitHub 示例文件:https://github.com/AndyIbanez/TutorialProjects/tree/master/launchnotifier

【问题讨论】:

    标签: ios objective-c cydia-substrate


    【解决方案1】:

    launch 适用于 iOS 6,您需要在 iOS 7 上使用 launchFromLocation:

    @interface SBIcon : NSObject
    - (void)launch; // iOS 6
    - (void)launchFromLocation:(NSInteger)location; //iOS 7
    @end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-06
      • 1970-01-01
      • 2020-09-19
      相关资源
      最近更新 更多