问题
I created a app to capture screenshot in background. It works well on iOS 7.x & 8.x, but failed to execute on iOS 9 beta. Here's my code:
CFMutableDictionaryRef sm = IOServiceMatching("AppleH1CLCD");
io_service_t ioService = IOServiceGetMatchingService(kIOMasterPortDefault, sm);
if (!ioService)
{
sm = IOServiceMatching("AppleM2CLCD");
ioService = IOServiceGetMatchingService(kIOMasterPortDefault, sm);
}
if (!ioService)
{
sm = IOServiceMatching("AppleCLCD");
ioService = IOServiceGetMatchingService(kIOMasterPortDefault, sm);
}
IOMobileFramebufferConnection connection = 0;
IOSurfaceRef ptr = nil;
IOMobileFramebufferReturn openMobileFrameBufferResult = IOMobileFramebufferOpen(ioService, mach_task_self(), 0, &connection);
if (openMobileFrameBufferResult)
{
return;
}
IOMobileFramebufferReturn getLayerDefaultSurfaceResult = IOMobileFramebufferGetLayerDefaultSurface(connection, 0, (CoreSurfaceBufferRef*)&ptr);
if (getLayerDefaultSurfaceResult)
{
return; // Here, the getLayerDefaultSurfaceResult is -536870201, not 0!
}
.......
When debugging it step by step, I found that the function IOMobileFramebufferGetLayerDefaultSurface failed to execute with a returning value -536870201 and the value expected was 0.
Who can tell me why this happened and how to resolve it ? thhhhhhhhhhhhhhhx!!
回答1:
Another user asked a similar question. I did some digging into IOMobileFramebufferGetLayerDefaultSurface
on iOS8 vs iOS9 (GM). And the results of what I found are summarized in this answer.
Given these results, I believe it is no longer possible, as of iOS9, to use IOMFB to capture the screen.
来源:https://stackoverflow.com/questions/32136308/iomobileframebuffergetlayerdefaultsurface-function-failed-on-ios-9