Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> iOS

ภาพหน้าจอ (Screenshot) ของ iOS Simulator เก็บอยู่ที่ไหน

ตำแหน่งเก็บ Screenshot ของ Simulator ขึ้นอยู่กับวิธีการถ่าย

1. Command + S หรือ File > New Screenshot

ตำแหน่ง: Desktop

ชื่อไฟล์: Simulator Screen Shot - iPhone 15 Pro - 2024-01-15 at 14.30.22.png

รูปแบบ: Simulator Screen Shot - {Device} - {YYYY-MM-DD at HH.MM.SS}.png

2. Command + Shift + 3 / 4 (macOS Screenshot)

ตำแหน่ง: Desktop (หรือตามตั้งค่า macOS Screenshot)

ชื่อไฟล์: Screen Shot 2024-01-15 at 14.30.22 PM.png

3. บันทึกลง Photos App ใน Simulator

หากแอปบันทึกลง UIImageWriteToSavedPhotosAlbum หรือ User Save จาก Share Sheet

ตำแหน่ง: ~/Library/Developer/CoreSimulator/Devices/{UDID}/data/Media/DCIM/

  • {UDID} = Unique ID ของ Simulator 那个 (ดูได้จาก xcrun simctl list devices)
  • โฟลเดอร์อาจเป็น 100APPLE หรือชื่อสุ่ม

วิธีหา UDID ของ Simulator

# Terminal
xcrun simctl list devices | grep Booted
# หรือ
xcrun simctl list devices

เคล็ดลับ

  • กด Command + Control + Shift + 4 แล้วกด Space → คลิกที่ Simulator Window → จับภาพเฉพาะหน้าต่าง Simulator (ไม่ต้อง Crop)
  • ใช้ xcrun simctl io booted screenshot screenshot.png ใน Terminal → บันทึกที่ Current Directory
  • เปลี่ยน Default Save Location ของ macOS Screenshot: defaults write com.apple.screencapture location ~/Pictures/Screenshots