ios - 'SpringBoard' 可能不会响应 presentViewController

标签 ios objective-c jailbreak theos springboard

我目前正在尝试对 iOS 9.3.3 进行一个非常简单的基线调整,以便在 Springboard 启动时显示一条消息。它一直给我这个错误,我不知道如何纠正它。任何帮助将不胜感激。我不使用 UIAlertView 的原因是它已被弃用。

错误:

> Making all for tweak UIAlertControllerTest
==> Preprocessing Tweak.xm
==> Compiling Tweak.xm (armv7)
Tweak.xm:9:8: error: 'SpringBoard' may not respond to
  'dismissViewControllerAnimated:completion:' [-Werror]
    [self dismissViewControllerAnimated:YES completion:nil];
     ~~~~ ^
Tweak.xm:12:8: error: 'SpringBoard' may not respond to
  'presentViewController:animated:completion:' [-Werror]
    [self presentViewController:alertController animated:YES complet...
     ~~~~ ^
2 errors generated.
make[3]: ***     [/home/theodd/Desktop/uialertcontrollertest/.theos/obj/debug/armv7/Tweak.xm.ae1dfb2c.o] Error 1
make[2]: ***     [/home/theodd/Desktop/uialertcontrollertest/.theos/obj/debug/armv7/UIAlertControllerTest.dylib] Error 2
make[1]: *** [internal-library-all_] Error 2
make: *** [UIAlertControllerTest.all.tweak.variables] Error 2

Tweak.xm:

#import <SpringBoard/SpringBoard.h>

%hook SpringBoard

-(void)applicationDidFinishLaunching:(id)application {
%orig;
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"TestTitle" message:@"TestMessage" preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[self dismissViewControllerAnimated:YES completion:nil];
}]];

[self presentViewController:alertController animated:YES completion:nil];
}

%end

最佳答案

SpringBoard 是一个 FBSystemApp,并且是 UIApplication 的子类,而不是 UIViewController。方法 -presentViewController:animated:completion: 是一个 UIViewController 实例方法,因此您想从其中调用它。

我建议您阅读一些关于类如何工作的文章,基本的 Objective-C 内容,不一定是特定于越狱的。

关于ios - 'SpringBoard' 可能不会响应 presentViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39645673/

相关文章:

iphone - Theos 制造问题

ios - 尝试创造命运之轮,创造轮子部分遇到困难

ios - 只有图像的自定义导航栏后退按钮

ios - ARC在Apple的UI库中的某个地方释放了我的对象

ios - 在特定索引路径行启动 TableView

ios - 从 NSMutableArray 中删除括号

ios - 包含多个并排表格 View 时,Scrollview scrollsToTop 不起作用?反复寻找

ios - 错误初始化 AZSCloudStorageAccount Swift 3

ios - 创建一个 iPhone 应用程序以在 iPhone 中拥有多个用户

iphone - iOS应用保护