Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The iOS SDK simulator makes it possible to test applications on the Macintosh using many of the same actions a user would perform on an actual device. Because the Macintosh is not a handheld touch-based mobile system, you must use menus, keyboard shortcuts, and the mouse or trackpad to approximate iPhone-style interactions. Table 3-1 shows how to perform these tasks via the simulator.
| Action | Simulator Equivalent |
|---|---|
| Selecting the device | Use Hardware > Device to simulate an original iPhone, Retina iPhone, or iPad-style device. Firmware versions are selectable via Hardware > Version. |
| Rotating the device | Hardware > Rotate Left (Command-left arrow) and Hardware > Rotate Right (Command-right arrow). The simulator supports all four major interface orientations: portrait, landscape left, landscape right, and portrait upside down. You cannot simulate face-up or face-down orientations. |
| Shaking the device | Hardware > Shake Gesture (Command-Control-Z). This simulates a shake using a motion event but does not simulate other accelerometer actions. I encourage you to avoid building applications that depend on users shaking devices, no matter how cool the feature appears. |
| Pressing the Home key | Click the Home button on the simulator screen or choose Hardware > Home (Command-Shift-H). |
| Locking the device | Hardware > Lock (Command-L). |
| Tapping and double-tapping | Click with the mouse, either a single- or double-click. |
| Tapping on the keyboard | Click the virtual keyboard or type on the Mac keyboard. You can use many Mac-style shortcuts for ease of testing, including Command-A, Command-C, and so on. |
| Dragging, swiping, and flicking | Click, drag, and release with the mouse. The speed of the drag determines the action. For flicks, drag very quickly. |
| Pinching in or out | Press and hold the Option key on your keyboard. When the two dots appear, drag them toward each other or away from each other. Hold down the Shift key to move the dot’s origin point. |
| Running out of memory | Hardware > Simulate Memory Warning. This allows you to simulate a condition of low available memory, letting you test how your application responds. |
| In-progress phone call (visual display only) | Hardware > Toggle In-Call Status Bar. On the iPhone, you can run an application while on a phone call. The in-call bar appears at the top of the screen for the duration of the call. |
| Attaching a keyboard | Simulate the detection of a Bluetooth or docked hardware keyboard by selecting Hardware > Simulate Hardware Keyboard. |
| Attaching TV Out cables | Choose Hardware > TV Out to simulate the attachment of a VGA or HDMI cable to the dock connector. Use this to test your external screen code, and specifically to catch screen-attached and -detached notifications. A floating window shows the simulated output. |
| Changing zoom | Change the magnification of the simulator by selecting Window > Scale. Choose from 100%, 75%, and 50%. |
| Simulating a printer | Choose File > Open Printer Simulator to test your software with AirPrint. You can also use this simulator to test printing from a device. The printed output opens in Preview. |
| Capturing screenshots | Choose File > Save Screen Shot (Command-S) or copy the screen with Edit > Copy Screen (Command-Control-C). |
| Setting a simulated location | Use the Debug > Location menu to simulate where the iPhone is being used. Choose from a (stationary) custom location, Apple’s HQ, Apple Stores, a city bike ride/run, or a drive down the freeway. |
| Slowing down animations | Choose Debug > Toggle Slow Animations to allow you to better view animations over a longer period of time. Use this feature to spot inconsistencies and flaws in your animations. |
| Highlighting potential rendering trouble spots | Use the four Debug > Color options to locate potential presentation issues. The items, which are toggled on and off via menu selection, include blended layers, copied images, misaligned images, and elements rendered off-screen. |
| Resetting the simulator | Choose iOS Simulator > Reset Contents and Settings to restore your simulator to its “factory fresh” original condition, deleting all current applications, settings, and user data. |