iOS(越狱)通过SBAppContextHostManager显示应用程序

iOS(越狱)通过SBAppContextHostManager显示应用程序,ios,objective-c,springboard,cydia-substrate,Ios,Objective C,Springboard,Cydia Substrate,基本上,我尝试使用SpringBoard的私有API SBAppContextHostManager来显示应用程序。到目前为止,我有以下代码: SBAppContextHostManager *app = [[objc_getClass("SBAppContextHostManager") alloc] init]; [app setAppBundleID:@"com.apple.springboard"]; // just as an example [app enableHostingF

基本上,我尝试使用SpringBoard的私有API SBAppContextHostManager来显示应用程序。到目前为止,我有以下代码:

SBAppContextHostManager *app = [[objc_getClass("SBAppContextHostManager") alloc] init];

[app setAppBundleID:@"com.apple.springboard"]; // just as an example

[app enableHostingForRequester:@"uniqueID" priority:1];

[app orderRequesterFront:@"uniqueID"];

SBHostWrapperView *view = [app hostViewForRequester:@"uniqueID"];
然后我打电话

UIGraphicsBeginImageContextWithOptions([UIScreen mainScreen].bounds.size, YES, [UIScreen mainScreen].scale);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetAllowsAntialiasing(c, YES);
[view.layer renderInContext:c];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

获取包含应用程序的视图的UIImage。但是,这个UIImage的输出是完全空白的,这使我认为对SBAppContextManager的调用是不正确的,从而导致SBHostWrapperView是空白的。因此,我应该如何以这种方式显示应用程序?

如果您试图获取应用程序的预览,则呈现SBHostWrapperView将不起作用。你看,SBHostWrapperViews不会复制应用程序的渲染输出,它只是在屏幕上为应用程序提供了一个不同的渲染位置

相反,您可以使用-SBFullscreenZoomView*SystemGestureSnapshot和ioSurface Snapshot of app:SBApplication*arg1 includeStatusBar:BOOLarg2;在斯伯勒班


该方法返回SBFullscreenZoomView(UIView的子类),其中包含arg1中提供的应用程序快照。您可以使用提供的第二段代码获取SBFullscreenZoomView的UIImage。这应该可以满足您的要求,只为您提供一个特定应用程序的屏幕截图。

干杯,这很好,除了在我的代码看起来像是在SD设备上一样稍微像素化后生成的图像之外。你知道为什么会这样吗?这很奇怪。你在用视网膜设备吗?此外,是否对图像应用任何变换?可能试试抗锯齿吧?是的,这是视网膜,图像上没有变换;我会尝试反走样,然后玩一玩缩放,结果发现我使用了错误的缩放;用正确的代码更新了问题。哦,顺便说一句,我发现这么问MobileSubstrate问题真的不是最好的地方。我正好在这里。我们大多数越狱开发者都会在irc.saurik.com的theos网站上闲逛。在那里提问很可能比在这里提问得到更好的回答;老实说,我一点也不知道这个频道存在!