Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Using the Simulator

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.

Table 3-1. Simulator Equivalents for iPhone Actions
ActionSimulator Equivalent
Selecting the deviceUse Hardware > Device to simulate an original iPhone, Retina iPhone, or iPad-style device. Firmware versions are selectable via Hardware > Version.
Rotating the deviceHardware > 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 deviceHardware > 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 keyClick the Home button on the simulator screen or choose Hardware > Home (Command-Shift-H).
Locking the deviceHardware > Lock (Command-L).
Tapping and double-tappingClick with the mouse, either a single- or double-click.
Tapping on the keyboardClick 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 flickingClick, drag, and release with the mouse. The speed of the drag determines the action. For flicks, drag very quickly.
Pinching in or outPress 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 memoryHardware > 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 keyboardSimulate the detection of a Bluetooth or docked hardware keyboard by selecting Hardware > Simulate Hardware Keyboard.
Attaching TV Out cablesChoose 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 zoomChange the magnification of the simulator by selecting Window > Scale. Choose from 100%, 75%, and 50%.
Simulating a printerChoose 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 screenshotsChoose File > Save Screen Shot (Command-S) or copy the screen with Edit > Copy Screen (Command-Control-C).
Setting a simulated locationUse 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 animationsChoose 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 spotsUse 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 simulatorChoose iOS Simulator > Reset Contents and Settings to restore your simulator to its “factory fresh” original condition, deleting all current applications, settings, and user data.



  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial