我目前正在尝试对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/