Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to simulate taking a screenshot in iOS simulator?

Tags:

Is there any way to simulate taking a screen shot on iOS simulator (equivalent of home + power on device)? My goal is NOT to save (cmd + s) or copy a shot of screen (from simulator menu items) but to capture UIApplicationUserDidTakeScreenshotNotification event.

like image 323
Edward Mehr Avatar asked Jan 29 '15 07:01

Edward Mehr


People also ask

How do I take a screenshot on iOS simulator?

Capturing device Screen − you can capture your Mac's screen from the area your simulator is running in. to do this you have to press, Command, shift and 4 at the same time, then drag to select the area you want to capture. Alternatively you can press 3 instead of 4 to capture the whole screen.

Where do iOS simulator screenshots go?

If you take a screenshot from within your app running on the simulator, and then save it to photos app on that simulator, then it is stored in some library folder of that specific Simulator.

How do you simulate Location on iphone simulator?

How to simulate location in Simulator. To simulate location on a Simulator, select Features menu > Location, then you will see a list of location and movement options you can simulate.

Which key is simulated gesture in iOS simulator?

Hold down the Option key. Move the circles that represent finger touches to the start position. Move the center of the pinch target by holding down the Shift key, moving the circles to the desired center position, and releasing the Shift key.


1 Answers

Use LLDB to mimic the screenshot NSNotification:

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

Pass --ignore-breakpoints false -- to the expr command if you want to stop at a breakpoint too:

(lldb) expr --ignore-breakpoints false -- [[NSNotificationCenter defaultCenter] postNotificationName:(NSNotificationName)UIApplicationUserDidTakeScreenshotNotification object:nil]
like image 107
Alan Zeino Avatar answered Oct 27 '22 07:10

Alan Zeino