ios - 如何在iOS模拟器中模拟截屏?

标签 ios ios-simulator

有什么方法可以模拟在 iOS 模拟器上截屏(相当于家庭 + 设备电源)?我的目标不是保存 (cmd + s) 或复制屏幕快照(从模拟器菜单项),而是捕获 UIApplicationUserDidTakeScreenshotNotification 事件。

最佳答案

使用LLDB模仿截图NSNotification:

(lldb) expr [[NSNotificationCenter defaultCenter] postNotificationName:(NSNotificationName)UIApplicationUserDidTakeScreenshotNotification object:nil]

如果您也想在断点处停止,请将 --ignore-breakpoints false -- 传递给 expr 命令:

(lldb) expr --ignore-breakpoints false -- [[NSNotificationCenter defaultCenter] postNotificationName:(NSNotificationName)UIApplicationUserDidTakeScreenshotNotification object:nil]

关于ios - 如何在iOS模拟器中模拟截屏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28209538/

相关文章:

visual-studio - Visual Studio 的 Windows iOS 模拟器无法启动,卡在 Xamarin 或 MAUI 的连接循环中

ios - 如何使用命令行从 iPhone 模拟器卸载应用程序?

iOS CoreBluetooth 无法在后台接收通知

ios - 为什么 view.layer.renderInContext() 对于相同大小的屏幕截图需要更多的临时内存

objective-c - UIBarButtonItem 没有响应点击

ios - ios推送通知延迟多少?

ios - Swift 3中的Google Maps API指南

xcode - 为什么在Xcode中进行构建会覆盖我的SQLite数据库?

iOS:处理 TARGET_IPHONE_SIMULATOR 宏

ios - Xcode 设备模拟器文件