首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >'SpringBoard‘可能对presentViewController没有响应

'SpringBoard‘可能对presentViewController没有响应
EN

Stack Overflow用户
提问于 2016-09-22 17:47:35
回答 3查看 954关注 0票数 0

我目前正试图为iOS 9.3.3做一个非常简单的基线调整,以便在Springboard启动时只显示一条消息。它不断地给我这个错误,我不知道如何纠正它。任何帮助都将不胜感激。我之所以不使用UIAlertView,是因为它不受欢迎。

误差

代码语言:javascript
复制
> 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

代码语言:javascript
复制
#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
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-09-26 14:41:11

我让它起作用了,伙计们!如果您想知道工作代码和Makefile是什么:

Tweak.xm

代码语言:javascript
复制
#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.keyWindow.rootViewController dismissViewControllerAnimated:YES completion:NULL];
}]];

    [self.keyWindow.rootViewController presentViewController:alertController animated:YES completion:NULL];
}

%end

Makefile

代码语言:javascript
复制
GO_EASY_ON_ME=1
export ARCHS = armv7 arm64
export TARGET = iphone:clang:9.3:9.3

include $(THEOS)/makefiles/common.mk

TWEAK_NAME = UIAlertControllerTest
UIAlertControllerTest_FRAMEWORKS = UIKit
UIAlertControllerTest_FILES = Tweak.xm

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
    install.exec "killall -9 SpringBoard"
票数 0
EN

Stack Overflow用户

发布于 2016-09-24 01:47:42

SpringBoard是一个FBSystemApp,扩展为UIApplication子类,而不是UIViewController。方法-presentViewController:animated:completion:是一个UIViewController实例方法,因此您需要从一个实例调用它。

我建议你阅读一下课程是如何工作的,基本的目标-C的东西,不一定非得是越狱专用的。

票数 1
EN

Stack Overflow用户

发布于 2016-09-24 20:22:29

或者只需使用UIAlertView,直到它们被废弃为止。例如:

UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"This is a title" message:@"This is a message" delegate:nil cancelButtonTitle:@"Ok!" otherButtonTitles:nil]; [a show]; [a release];

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39645673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档