我一直在寻找一种方法来确定iOS外部屏幕是否有线连接或通过无线方式找不到任何明显的方法.
我在这里看过非官方的AirPlay规格,但看不到任何明显的检测方法.有没有人知道是否可以使用legal /'public'API完成此操作.
我正在使用CATiledLayer支持的NSView(Mac而不是iOS),根据Apple文档https://developer.apple.com/reference/quartzcore/catiledlayer我希望在多个线程上异步调用它以帮助提高性能,不过它似乎只是在主线程上被调用.
我正在做的工作 drawLayer(layer: CALayer, inContext ctx: CGContext)
我已经canDrawConcurrently在NSView上启用了以及确保窗口allowsConcurrentViewDrawing设置为true(默认),但它仍然总是调用每个tile rect的主线程.
我需要在显示之前进行一些图像处理,这取决于需要显示的矩形区域,并且在主线程上运行会影响性能.
任何想法我怎么能强迫它在后台线程上调用?
我已经尝试将操作编组到后台线程上,然后使用以下内容调用主队列,但它显示一个空白的矩形:
backgroundQueue.addOperationWithBlock({ [ weak self ] in
guard let strongSelf = self else { return }
// ** This is the part I nee to do in background that can take some time
guard let image = strongSelf.imageForTileRect(layerBounds, imageSize: imageSize) else { return }
// ** End background bit
var rect = layerBounds
let rectImageRef = image.CGImageForProposedRect(&rect, context: nil, hints: nil)
if (rectImageRef …Run Code Online (Sandbox Code Playgroud)