SLDevice Class Reference
Inherits from | NSObject |
Declared in | SLDevice.h |
Overview
The singleton SLDevice
instance allows you to access and manipulate
the device on which your application is running.
Tasks
Getting the Shared Instance
-
+ currentDevice
Returns an object representing the current device.
Interacting with Hardware Buttons
-
– deactivateAppForDuration:
Deactivates your application for the specified duration.
Device Orientation
-
– setOrientation:
Changes the device orientation to the specified new
deviceOrientation
value.
Screenshots
-
– captureScreenshotWithFilename:
Takes a screenshot of the entire device screen.
-
– captureScreenshotWithFilename:inRect:
Takes a screenshot of the specified rectangular portion of the device screen.
Instance Methods
captureScreenshotWithFilename:
Takes a screenshot of the entire device screen.
- (void)captureScreenshotWithFilename:(NSString *)filename
Parameters
- filename
A string to use as the name for the resultant image file.
Discussion
The image is viewable from the UIAutomation debug log in Instruments.
When running subliminal-test
from the command line, the images are also saved
as PNGs within the specified output directory.
Declared In
SLDevice.h
captureScreenshotWithFilename:inRect:
Takes a screenshot of the specified rectangular portion of the device screen.
- (void)captureScreenshotWithFilename:(NSString *)filename inRect:(CGRect)rect
Parameters
- filename
A string to use as the name for the resultant image file.
- rect
The rect that defines the area of the screen to capture.
Discussion
The image is viewable from the UIAutomation debug log in Instruments.
When running subliminal-test
from the command line, the images are also saved
as PNGs within the specified output directory.
Exceptions
- NSInternalInconsistencyException
if
rect
isCGRectNull
.
Declared In
SLDevice.h
deactivateAppForDuration:
Deactivates your application for the specified duration.
- (void)deactivateAppForDuration:(NSTimeInterval)duration
Parameters
- duration
The time, in seconds, for the app to remain inactive (subject to the caveat in the discussion).
Discussion
By pushing the Home button, waiting for the specified duration, and then using the app switcher to reactivate the application.
This method will not return until the app reactivates.
Note that the time spent inactive will actually be a few seconds longer than specified; UIAutomation lingers upon the app switcher for several seconds before actually tapping the app.
Declared In
SLDevice.h
setOrientation:
Changes the device orientation to the specified new deviceOrientation
value.
- (void)setOrientation:(UIDeviceOrientation)deviceOrientation
Parameters
- deviceOrientation
The device orientation to rotate to.
Discussion
You can access the current device orientation using [[UIDevice currentDevice] orientation]
.
Declared In
SLDevice.h