You are previewing iOS Development with Xamarin Cookbook.
O'Reilly logo
iOS Development with Xamarin Cookbook

Book Description

Over 100 exciting recipes to help you develop iOS applications with Xamarin

In Detail

This book will provide you with the necessary knowledge and skills to be part of the mobile development era, using C#. Covering a wide range of recipes such as creating a simple application and using device features effectively, it will be your companion to the complete application development cycle.

Starting from installing the necessary tools, you will be guided step-by-step on everything you need to develop an application ready to be deployed. You will learn the best practices for interacting with the device hardware, such as the GPS, compass, and the accelerometer. Furthermore, you will be able to manage multimedia resources such as photos and videos captured with the device camera, and much more!

What You Will Learn

  • Install and use Xamarin.iOS with Xamarin Studio
  • Design an application's User Interface with Xcode
  • Explore the key concepts and effective usage instructions of iOS UI elements
  • Capture and manage multimedia resources using the device's camera and microphone
  • Use the accelerometer to capture and respond to device motion
  • Create location-aware applications using the built-in GPS, compass, and mapping features
  • Effectively use multitasking features to provide a user-friendly experience
  • Discover and explore new iOS 7 features
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. iOS Development with Xamarin Cookbook
      1. Table of Contents
      2. iOS Development with Xamarin Cookbook
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Development Tools
        1. Introduction
        2. Installing prerequisites
          1. Getting ready
          2. How to do it...
          3. How it works...
            1. Xcode
            2. Interface Builder
            3. iOS Simulator
          4. There's more...
            1. Useful links
            2. Updates
          5. See also
        3. Creating an iOS project with Xamarin Studio
          1. Getting ready...
          2. How to do it...
          3. How it works...
            1. MyFirstiOSProjectViewController.xib
            2. MyFirstiOSProjectViewController.cs
            3. MyFirstiOSProjectViewController.designer.cs
            4. AppDelegate.cs
            5. Main.cs
            6. Info.plist
          4. There's more...
            1. List of Xamarin.iOS assemblies
          5. See also
        4. Interface Builder
          1. How to do it...
          2. How it works...
          3. There's more...
            1. More information
          4. See also
        5. Creating the UI
          1. Getting ready
          2. How to do it...
            1. Adding a label
            2. Adding a button
          3. How it works...
          4. There's more...
            1. Setting titles on Buttons
          5. See also
        6. Accessing the UI with Outlets
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Adding Outlets through code
          5. See also
        7. Adding Actions to controls
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Compiling an iOS project
          1. Getting ready
          2. How to do it...
          3. How it works...
            1. iOS build options
            2. iOS application options
          4. There's more...
          5. See also
        9. Debugging our application
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. App performance when debugging
            2. Breakpoints in FinishedLaunching
          5. See also
      9. 2. User Interface – Views
        1. Introduction
        2. Adding and customizing views
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Adding views programmatically
            2. View content layout
          5. See also
        3. Receiving user input with buttons
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Changing the appearance of buttons
          5. See also
        4. Displaying images
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Using images for different screen sizes
          5. See also
        5. Displaying and editing text
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Using the keyboard
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Displaying progress
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. UIProgressView height
          5. See also
        8. Displaying content larger than the screen
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. UIScrollView events
          5. See also
        9. Navigating through the content divided into pages
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Proper usage of UIPageControl
          5. See also
        10. Displaying alerts
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
          5. See also
        11. Creating a custom view
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Styling views
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Limitations of UIAppearance
          5. See also
      10. 3. User Interface – View Controllers
        1. Introduction
        2. Loading a view with a view controller
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. UIViewController methods to override
          5. See also
        3. Navigating through different view controllers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Managing navigation bar buttons
          5. See also
        4. Providing controllers in tabs
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
            1. Useful UITabBarController properties
            2. Determining tab selection
          5. See also
        5. Modal view controllers
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
            1. Accessing a modal controller
              1. How many modal controllers?
          5. See also
        6. Creating a custom view controller
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Using view controllers efficiently
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
          5. See also
        8. iPad view controllers
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
            1. iPad-specific controller usage
          5. See also
        9. UI flow design with storyboards
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Passing data
          5. See also
        10. Unwinding in storyboards
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Where is the unwind segue in the storyboard?
          5. See also
      11. 4. Data Management
        1. Introduction
        2. Creating files
          1. Getting ready
          2. How to do it…
          3. How it works...
          4. There's more...
            1. The Documents folder
            2. The Caches folder
          5. See also
        3. Using a SQLite database
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. SQL table creation
          5. See also
        4. Preparing for iCloud support
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. iCloud key/value storage
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Getting notified on key/value store changes
          5. See also
      12. 5. Displaying Data
        1. Introduction
        2. Providing lists
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More UIPickerView customization
            2. Date and time selection
          5. See also
        3. Displaying data in a table
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. The UITableView styles
            2. The UITableViewCell styles
          5. See also
        4. Customizing rows
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Useful properties of the UITableViewCell class
            2. UINib class
            3. Adding content programmatically
          5. See also
        5. Editing a table
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Enabling editing modes for individual rows
          5. See also
        6. Table indexing
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Searching through the data
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Creating a simple web browser
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Scaling the content
            2. UIWebView supported files
        9. Displaying data in a grid
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More information on UICollectionView
          5. See also
        10. Customizing the grid
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      13. 6. Web Services
        1. Introduction
        2. Consuming web services
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Invoking web service methods asynchronously
            2. The XSP shutdown
          5. See also
        3. Consuming REST services
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Communicating with native APIs
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Synchronous NSUrlConnection
            2. Usability
          5. See also
        5. Using WCF services
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More information on Xamarin Studio's WCF support
            2. WCF service creation
          5. See also
      14. 7. Multimedia Resources
        1. Introduction
        2. Selecting images and videos
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Picking videos
          5. See also
        3. Capturing media with the camera
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Image editing
          5. See also
        4. Playing videos
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Wireless streaming
          5. See also
        5. Playing music and sounds
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Playing sound files
          5. See also
        6. Recording with the microphone
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Recording for a predefined amount of time
          5. See also
        7. Managing album items directly
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Reading EXIF data
            2. Retrieving individual assets
            3. Checking for permission
          5. See also
      15. 8. Integrating iOS Features
        1. Introduction
        2. Starting phone calls
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More information on OpenUrl
          5. See also
        3. Sending text messages and e-mails
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More information on opening external apps
          5. See also
        4. Using text messaging in our application
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Attachments
        5. Using e-mail messaging in our application
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Managing the address book
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Adding a phone number to a contact
        7. Displaying contacts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Other address book controllers
          5. See also
        8. Managing the calendar
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Reminders
          5. See also
      16. 9. Interacting with Device Hardware
        1. Introduction
        2. Detecting the device orientation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. The device orientation and user interface orientation
          5. See also
        3. Adjusting the UI orientation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. User interface orientation on child controllers
          5. See also
        4. Proximity sensor
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Retrieving the battery information
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Disabling battery monitoring
          5. See also
        6. Handling motion events
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More information on motion events
          5. See also
        7. Handling touch events
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Getting the tap count
          5. See also
        8. Recognizing gestures
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. The advantage of gesture recognizers
          5. See also
        9. Custom gestures
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Another use of custom gesture recognizers
          5. See also
        10. Using the accelerometer
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Consideration when using the accelerometer
          5. See also
        11. Using the gyroscope
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Determining the availability of the gyroscope hardware
            2. Converting radians to degrees
          5. See also
      17. 10. Location Services and Maps
        1. Introduction
        2. Determining location
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. GPS accuracy
            2. Location services availability
            3. Location services usage indicator
          5. See also
        3. Determining heading
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Magnetic vs true heading
            2. Compass availability
          5. See also
        4. Using region monitoring
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Region monitoring availability
          5. See also
        5. Using a significant-change location service
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Significant-change location service availability
          5. See also
        6. Location services in the background
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Restricting to supported hardware
            2. UI updates while in the background
          5. See also
        7. Displaying maps
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Geocoding
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Things to have in mind for CLGeocoder
            2. Obsolete API
          5. See also
        9. Adding map annotations
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. An annotation's performance
          5. See also
        10. Adding map overlays
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Creating custom overlays
            2. Standard overlay objects
          5. See also
      18. 11. Graphics and Animation
        1. Introduction
        2. Animating views
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Animatable properties
        3. Transforming views
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Transformation and Frame
          5. See also
        4. Animating images
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Checking for animation
          5. See also
        5. Animating layers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Layers
          5. See also
        6. Drawing lines and curves
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Graphics context on a UIImageView class
          5. See also
        7. Drawing shapes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Transparent colors
          5. See also
        8. Drawing text
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Size of the drawn text
          5. See also
        9. A simple drawing app
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Clear the drawing
          5. See also
        10. Creating an image context
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Drawing on UIImageView
            2. Background on saved drawings
          5. See also
      19. 12. Multitasking
        1. Introduction
        2. Detecting application states
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Proper usage
        3. Receiving notifications for app states
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Removing notification observers
          5. See also
        4. Running code in the background
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Important considerations for the background code
          5. See also
        5. Playing audio in the background
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. The background state for audio
          5. See also
        6. Updating data in the background
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more
            1. UI updates
          5. See also
      20. 13. Localization
        1. Introduction
        2. Creating an app for different languages
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Localization in real-world app scenarios
            2. The localizable.strings encoding
        3. Localizable resources
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More information on localizable resources
          5. See also
        4. Regional formatting
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      21. 14. Deploying
        1. Introduction
        2. Creating profiles
          1. How to do it...
          2. How it works...
          3. There's more...
            1. Expiration of provisioning profiles
          4. See also
        3. Creating an ad hoc distribution bundle
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Syncing ad hoc app bundles with iTunes
          5. See also
        4. Preparing an app for the App Store
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. The 4-inch screen launch image
          5. See also
        5. Submitting an app to the App Store
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      22. 15. Advanced Features
        1. Introduction
        2. Reproducing the page curl effect
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Double-sided pages
        3. Integrating content sharing
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        4. Implementing custom transitions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Transitioning between child controllers
          5. See also
        5. Using physics in UI elements
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. UIKit Dynamics usage
        6. Implementing the text-to-speech feature
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
            1. Adjusting the utterance
      23. Index