Home Page Icon
Home Page
Table of Contents for
About the Author
Close
About the Author
by Bryan Costanich
Developing C# Apps for iPhone and iPad Using MonoTouch: iOS Apps Development for .NET Developers
Copyright
About the Author
About the Technical Reviewer
Acknowledgments
Preface
1. Getting Started with MonoTouch
1.1. Developing for the iPhone and iPad
1.1.1. Limited Multitasking
1.1.2. Limited System Resources
1.1.3. Small Screen Size
1.1.4. Device-specific Technology
1.1.5. Constrained Response Time
1.1.6. Constrained Access
1.2. MonoTouch Background
1.2.1. iPhone vs. iPod Touch vs iPad?
1.2.2. How Does It Work?
1.2.3. How Do I Build a User-Interface (UI); Can I Use Silverlight?
1.2.4. How Do I Distribute My Apps?
1.2.5. What Is the Licensing Model?
1.2.6. Are There Any Limitations of MonoTouch?
1.2.6.1. No Just-in-Time (JIT) Compilation
1.2.6.2. C# Is Currently the Only Language
1.2.6.3. More Information
1.3. Getting Started
1.3.1. Mac Computer Running Snow Leopard
1.3.2. Apple's iOS SDK
1.3.3. Mono for OSX
1.3.4. MonoTouch SDK
1.3.5. Text Editor or Integrated Development Environment
1.3.6. Documentation
1.3.6.1. Xcode/iOS Documentation
1.3.6.2. MonoTouch Rosetta Stone
1.3.7. Resources
1.3.8. 3rd Party Libraries
1.4. Summary
2. Our First Application
2.1. Starting the Example
2.1.1. Create a New Solution
2.1.2. Examining the Code
2.2. Interface Builder
2.2.1. Exploring Interface Builder
2.2.2. Building the Interface
2.3. Outlets
2.3.1. Outlets Exposed to Code
2.3.2. Running the Application
2.4. Actions
2.4.1. Adding an Action
2.4.2. Actions in Code
2.5. Choosing Which Device to Simulate
2.6. Application Name and Icons
2.6.1. Application Name
2.6.2. Application Icons
2.7. Summary
3. Creating Multi-Screen Applications Using the MVC Pattern
3.1. Model-View-Controller (MVC) Pattern
3.1.1. Model
3.1.2. View
3.1.3. Controller
3.2. Benefits of the MVC Pattern
3.3. Views and View Controllers in MonoTouch
3.4. Sample Application
3.4.1. Adding the Navigation Controller to the Main Screen
3.4.2. HelloWorld and HelloUniverse Screens
3.4.3. Showing Different Screens
3.4.3.1. MainScreen.xib.cs
3.4.3.2. AppDelegate
3.5. Summary
4. iPad and Universal (iPhone/iPad) Applications
4.1. A Note About Resolution on the iPhone
4.2. Creating an iPad-Only Application
4.2.1. Changing Common Settings in MonoDevelop
4.2.2. iPad Screens in Interface Builder
4.3. Creating a Universal iPhone/iPad Application
4.3.1. Method 1: Universal Project Template
4.3.2. Method 2: Programmatic Device Detection
4.3.2.1. Determining the Device Type
4.3.2.2. Creating a Custom AppDelegate
4.3.2.3. Creating a Custom Main Method
4.4. Summary
5. More on Views and Controllers
5.1. Custom UIViewController and UIView Implementations
5.1.1. Default UIView Constructor for a View Defined in a xib file
5.1.2. Manually Loading a UIView Defined in a .xib File
5.1.3. UIViewController Event Lifecycle
5.1.3.1. LoadView
5.1.3.2. ViewDidLoad
5.1.3.3. ViewDidUnload
5.1.3.4. ViewWillAppear
5.1.3.5. ViewWillDisappear
5.1.3.6. Other Methods
5.1.4. UIView Event Lifecycle
5.1.4.1. Constructor
5.1.4.2. Draw
5.1.4.3. LayoutSubviews
5.2. Managing More than One View in a Controller
5.2.1. Switching Views
5.2.2. Animating the Transition
5.3. Handling Rotation
5.3.1. Rotation Lifecycle Events in UIViewController
5.3.1.1. ShouldAutorotateToInterfaceOrientation
5.3.1.2. WillAnimateRotation
5.3.1.3. WillRotate
5.3.1.4. DidRotate
5.3.1.5. WillAnimateFirstHalfOfRotation and WillAnimateSecondHalfOfRotation
5.3.2. General Approaches to Rotation
5.3.2.1. Autosizing
5.3.2.2. Moving Controls
5.3.2.3. Swapping Views
5.3.3. Rotation Review
5.4. Summary
6. Introduction to Controls
6.1. Coordinate System
6.1.1. Frame
6.2. Autosizing
6.3. Working with Fonts
6.3.1. Font Sizes
6.3.2. Enumerating Fonts
6.4. Tags
6.5. Control States
6.6. Working with Images
6.6.1. FromFile vs. FromBundle
6.6.1.1. FromBundle
6.6.1.2. FromFile
6.6.2. Which One?
6.7. Subclassing (Creating Custom Controls)
6.7.1. Necessary Constructors
6.7.2. Registering Your Controls
6.7.3. Using Your Controls in Interface Builder
6.8. Prototypes vs. Delegates vs. Events, What?
6.8.1. Protocols
6.8.2. Delegates
6.8.3. Weak-Delegates
6.9. Updating Your Controls from the UI Thread
6.10. Summary
7. Standard Controls
7.1. UILabel
7.1.1. Text Wrapping Options
7.1.1.1. Number of Lines
7.1.2. UITextField
7.1.3. Borders
7.1.4. Text Value
7.1.5. Default Placeholder Text
7.1.6. Keyboards
7.2. UIButton
7.2.1. Handling 'Clicks'
7.2.2. Different Types of Buttons
7.2.3. Button Text
7.3. UIImage
7.3.1. Animating an Image View
7.4. UIScrollView
7.4.1. Zooming
7.4.2. Implementing Tap-to-Zoom
7.4.3. Scroll Paging
7.5. UISegmentedControl
7.5.1. Configuring the Segmented Control
7.5.2. Specifying Segment Sizes
7.5.3. Handling Button Presses
7.6. UISwitch
7.7. UISlider
7.7.1. Images
7.7.2. Accessing the Value
7.8. UIActivityIndicatorView
7.9. UIProgressView
7.9.1. Setting the Progress Value
7.10. UIPagerControl
7.10.1. Page Changes via the Pager Control
7.10.2. Updating the Pager Control When the Page is Scrolled to Via a Scroll View
7.11. UIAlertView
7.11.1. Alerts and Garbage Collection
7.11.2. Working with Buttons
7.11.3. Alert Delegate
7.11.4. Customizing the Alert View Even Further
7.12. UIActionSheet
7.12.1. Creating a Simple Action Sheet
7.12.2. Button Types
7.12.3. Adding Custom Buttons
7.12.4. Displaying an Action Sheet
7.12.5. Subclassing
7.13. UIDatePicker
7.13.1. Configuration
7.13.2. Showing Dynamically
7.14. UIPickerView
7.14.1. Populating the Picker
7.14.2. UIPickerViewModel
7.15. UIToolbar
7.15.1. Item Types
7.15.2. Toolbars in Interface Builder
7.15.3. Programmatic Creation
7.15.4. Sizing
7.15.5. Handling Clicks
7.16. Summary
8. Content Controls
8.1. Navigation Controller
8.1.1. Parts of the Navigation Controller
8.1.2. Using the Navigation Controller
8.1.3. Modifying the Navigation Bar
8.1.3.1. Title
8.1.3.2. Style
8.1.3.3. TintColor
8.1.3.4. Opacity
8.1.3.5. Right Button
8.1.4. Navigation Toolbar
8.2. Tab Bar Controller
8.2.1. Creating a Tab Bar Controller
8.2.1.1. Tab Bar Items
8.2.1.2. Using a Custom Tab Bar Controller
8.2.1.3. User Customizable Tabs
8.2.1.4. Tab Badges
8.3. Split View Controller
8.3.1. Using the Split View
8.3.1.1. Creating Views for the Split View
8.3.1.2. Showing and Hiding the Button to Show the Master View
8.3.1.3. Communicating Between the Master and Detail View
8.4. Web View
8.4.1. Using the Web View
8.4.1.1. NSUrl
8.4.1.2. Navigation
8.4.1.3. Events
8.4.1.3.1. LoadStarted
8.4.1.3.2. LoadingFinished
8.4.1.3.3. LoadError
8.4.2. Loading Local Content
8.4.3. Interacting with Page Content
8.4.3.1. Running JavaScript
8.4.3.2. Listening for Events
8.4.4. Loading Non-Web Documents
8.5. Map View
8.5.1. Using the Map View
8.5.1.1. Different Map Modes
8.5.2. Using Device Location
8.5.3. Annotating the Map
8.5.3.1. GetViewForAnnotation
8.5.3.2. Annotation Views
8.5.3.3. MKPinAnnotationView
8.5.3.4. Handling Annotation Callout Clicks
8.5.3.5. Annotation Performance Considerations
8.5.4. User Overlays
8.5.4.1. Creating the Overlay
8.5.4.2. Adding the Overlay
8.5.4.3. Implementing GetViewForOverlay
8.6. Search Bar
8.7. Summary
9. Working with Tables
9.1. Parts of the UITableView
9.2. Populating a Table
9.2.1. UITableViewSource
9.3. Responding to User Interaction
9.4. UITableViewController
9.5. Refreshing the Table When Data Changes
9.6. Customizing the Appearance of a Table View
9.6.1. Table Styles
9.6.2. Providing a Table Index
9.6.3. Cell Styles
9.6.3.1. Cell Accessories
9.6.3.2. Other Cell Customizations
9.6.4. Custom Cells
9.6.4.1. Creating a Custom Cell in Interface Builder
9.6.4.2. Creating a Custom Cell in Code
9.7. Editable Tables
9.7.1. Editing Methods
9.7.1.1. CommitEditingStyle Method
9.7.1.2. MoveRow Method
9.7.2. Deleting Items
9.7.3. Advanced Table Editing
9.8. Table Performance Considerations
9.8.1. Cell Reuse
9.8.2. Cache the Row Height
9.8.3. Cache Images
9.8.4. Avoid Transparency
9.8.5. Manually Draw the Cell
9.8.6. Avoid Complex Graphical Computations
9.8.7. Create Your Cell in Code
9.8.8. Further Optimizations
9.9. Summary
10. Working with Keyboards
10.1. Keyboard/Input Properties
10.1.1. Capitalization
10.1.2. Correction
10.1.3. Keyboard
10.1.4. Return Key
10.1.5. Languages
10.2. Hiding the Keyboard
10.3. Making Input Fields Visible When the Keyboard Covers Them
10.4. Summary
11. Multitasking
11.1. Application States
11.2. Understanding Background Tasks
11.2.1. Checking for Multitasking Capability
11.2.2. Application Delegate Methods
11.2.3. Multitasking Guidelines and Requirements
11.3. Asking the iOS for Time to Complete a Task
11.3.1. Task Execution Expiration Time
11.3.2. Task Completion Patterns
11.4. Registering Your Application to be Allowed to Perform a Particular Background Task Category
11.5. Audio Applications
11.6. Location Applications
11.7. VoIP Applications
11.7.1. VoIP Socket Handling
11.7.2. VoIP Keep-alive
11.8. Summary
12. Working with Touch
12.1. When to Use Which?
12.2. Enabling Touch
12.3. Touch Events
12.3.1. The UITouch Class
12.3.2. Using Touch Events
12.3.2.1.
12.3.2.1.1. Multi-Taps
12.3.2.1.2. Multi-Touch
12.3.2.2. Determining Touch Location
12.3.2.3. Example Application
12.3.2.4. Touch Me Image
12.3.2.5. Double-Tap Me Image
12.3.2.6. Drag Me Image
12.4. Gesture Recognizers
12.4.1. Using Gesture Recognizers
12.4.1.1. Creating the Gesture Recognizer
12.4.1.2. Configuring the Gesture
12.4.1.3. Configuring the Target
12.4.1.3.1. Using an Anonymous Delegate or Lambda
12.4.1.3.2. Using the Selector Pattern
12.4.1.4. Enabling Gesture Recognition
12.4.1.5. Adding the Gesture to a View
12.4.2. Retrieving Gesture Information
12.4.2.1. Gesture Recognizer States
12.4.3. Example Using the Tap Gesture
12.4.4. Example Using the Pan Gesture to Drag an Object
12.4.4.1. Working with Multiple Gesture Recognizers
12.4.4.1.1. Allowing Simultaneous Gesture Recognition
12.4.4.1.2. Disabling Another Gesture
12.4.4.1.3. Requiring Another Gesture to Fail Before One Succeeds
12.4.5. Allowing Gestures and Touch Events Simultaneously
12.4.6. Creating a Custom Gesture
12.4.6.1. Checkmark Gesture Recognizer Example
12.4.6.2. Reset Method
12.4.6.3. Using the Custom Gesture Recognizer
12.5. Summary
13. Working with Shared Resources
13.1. File System
13.1.1. Case-Sensitivity
13.1.2. Application Sandbox
13.1.3. Application Directories
13.1.4. Backup/Restore
13.1.5. Application Updates
13.2. Device Battery
13.2.1. Battery Level
13.2.2. Battery State
13.2.3. Getting Battery Change Notifications
13.3. Address Book/Contacts
13.3.1. Address Book Controllers
13.3.1.1. People Picker View Controller (Contact Picker)
13.3.1.1.1. Cancelled Event
13.3.1.1.2. SelectPerson Event
13.3.1.2. Person View Controller
13.3.1.3. New Person View Controller
13.3.1.3.1. NewPersonComplete Event
13.3.1.4. Unknown Person View Controller
13.3.1.4.1. PersonCreated Event
13.3.2. Working Directly with the Address Book
13.3.2.1. Address Books (ABAddressBook)
13.3.2.1.1. Change Notifications
13.3.2.2. Records
13.3.2.3. Record Properties
13.4. Photos and Camera
13.4.1. UIImagePickerController
13.4.1.1. Determining Support
13.4.1.1.1. Sources
13.4.1.1.2. Cameras and Flash
13.4.1.1.3. Media Types
13.4.1.2. Creating the Image Picker
13.4.1.3. Configuring the Image Picker
13.4.1.3.1. Source
13.4.1.3.2. Media Types
13.4.1.3.3. Camera Controls
13.4.1.4. Providing a Custom Camera Overlay
13.4.1.5. Displaying the Image Picker
13.4.1.6. Handling Image Picker Events
13.4.1.7. Implementing a UIImagePickerControllerDelegate
13.4.1.8. Canceled Event/Method
13.4.1.9. FinishedPickingMedia Event/Method
13.4.2. AV Foundation Framework
13.4.2.1. Enumerating User Albums
13.5. Network Activity Indicator
13.6. Accelerometer
13.6.1.
13.6.1.1. Shake Gesture
13.7. Summary
14. User and Application Settings
14.1. Working with Settings in the iOS
14.2. Registering Settings with the Settings Application
14.2.1. Creating a Settings Bundle
14.2.2. Creating the Property List File
14.2.2.1. Property Specifier Schema
14.2.2.2. PSGroupSpecifier
14.2.2.3. PSTextFieldSpecifier
14.2.2.4. PSTitleValueSpecifier
14.2.2.5. PSSliderSpecifier
14.2.2.6. PSToggleSwitchSpecifier
14.2.2.7. PSMultiValueSpecifier
14.2.2.8. PSChildPaneSpecifier
14.3. Accessing Settings
14.4. Saving Settings
14.5. Initializing Settings
14.6. Summary
15. Working with CoreLocation
15.1. Under the Hood
15.2. Usage Pattern
15.3. Instantiating CLLocationManager
15.4. Configuring the Location Manager
15.4.1. Update Threshold
15.4.2. Accuracy
15.5. Listening for Updates
15.5.1. UpdatedLocation
15.5.1.1. CLLocation
15.5.2. UpdatedHeading
15.5.2.1. CLHeading
15.6. Starting the Location Service Updates
15.6.1. Capabilities
15.7. Stopping Updates
15.8. Battery Drain
15.9. Summary
16. Drawing with CoreGraphics
16.1. Painter's Model
16.2. Performance
16.3. Colors
16.3.1. A Bit o' Color Theory
16.3.2. Alpha RGB
16.3.3. UIColor and CGColor
16.4. Drawing Context
16.4.1. Drawing Onscreen
16.4.2. Drawing Off-Screen
16.4.2.1. CGBitmapContext
16.4.2.2. CGLayer
16.5. CoreGraphics Coordinate System
16.5.1. Transforming the Context Coordinate Space
16.5.2. Transforming the Coordinates of Individual Drawing Operations
16.6. Drawing Tools
16.6.1. Paths
16.6.1.1. Stroking and Filling Paths
16.6.2. Primitives
16.6.3. Text
16.6.4. Images
16.6.5. Patterns
16.6.5.1. Creating a Color Pattern
16.6.5.2. Creating a Stencil Pattern
16.6.6. Shadows
16.6.6.1. Grayscale Shadows
16.6.6.2. Color Shadows
16.7. Transformations
16.7.1.
16.7.1.1. Translation (Moving)
16.7.1.2. Scaling
16.7.1.3. Rotation
16.7.1.4. Custom Transforms
16.8. Hit Testing
16.9. Updating the Drawing Surface in Real-time
16.9.1. Full View Update
16.9.2. Partial View Updates
16.10. Other Features of CoreGraphics
16.11. Summary
17. Core Animation
17.1. View-Based Animation Framework
17.1.1. View Animations via the Animation Blocks
17.1.2. View Animations via Block-Based Animation
17.1.3. Comparison of the Two Approaches
17.1.4. What Is Animatable?
17.1.5. Configuring Animation Behavior
17.1.5.1. Nested Animations
17.1.5.2. Specifying Behavior via Animate Method Overloads
17.1.5.2.1. UIViewAnimationOptions Enumeration
17.1.6. Animation Curves
17.1.7. View Transitions
17.1.8. Specifying Behavior via Methods
17.2. Advanced Core Animation with Layers
17.2.1. Layer-Based Animation
17.2.2. Layer Animation Types
17.2.2.1. Explicit Animations
17.2.2.1.1. Animation Types
17.2.2.2. Creating CALayers Manually
17.2.2.3. Drawing Layers on a View
17.2.2.4. Implicit Animations
17.3. Summary
18. Notifications
18.1. How Notifications Work
18.2. Scheduling Local Notifications
18.3. Handling Notifications
18.4. Push Notifications
18.4.1. Restrictions and Limitations
18.4.2. The Sandbox and Production Environments
18.4.3. APNS-Sharp
18.4.4. Identifying Devices
18.4.4.1. Registering for Remote Notifications and Getting a Device Token
18.4.4.1.1. Registering to Receive Remote Notifications in iOS
18.4.4.1.2. Receiving the Token
18.4.4.1.3. Listening for Registration Failure
18.4.4.2. Retrieving Expired Tokens with the Feedback Service
18.4.5. Creating a Push Notification Certificate
18.4.6. Creating and Installing a Provisioning Profile
18.4.7. Sending Push Notifications
18.4.7.1. Converting the Certificate
18.4.7.2. Sending a Notification
18.5. Summary
19. Working with Data
19.1. SQLite
19.1.1. Limitations of SQLite
19.1.2. Version Matrix
19.1.3. Creating a Database
19.2. Backups and Data Update Strategy
19.2.1. Backups
19.2.2. Application Updates
19.3. Data Access Technologies
19.3.1. ADO.NET
19.3.1.1. Creating a Database
19.3.1.2. Creating a Schema and Adding Data
19.3.1.3. Selecting Data
19.3.2. SQLite-Net
19.3.2.1. Database Creation
19.3.2.2. Object Mapping
19.3.2.3. Table Creation and Data Import
19.3.2.4. Selecting Data
19.3.3. Vici CoolStorage
19.3.3.1. Object Mapping
19.3.3.2. Creating a Database
19.3.3.3. Table Creation and Data Import
19.3.3.4. Query Data
19.3.4. NHibernate
19.4. Summary
20. Publishing to the App Store
20.1. Review Guideline Conformity
20.1.1. Apple Blog
20.2. Building for Distribution
20.2.1. Creating and Installing a Distribution Provisioning Profile
20.2.2. Adding a Distribution Build Configuration
20.2.3. Configure Distribution Bundle Signing
20.2.4. Building
20.2.4.1. Having MonoDevelop Build and Zip for You
20.2.4.2. Manually Building and Zipping
20.3. Submitting Your App via iTunes Connect
20.4. Application Rejection Dispute Resolution
20.5. Summary
21. Third-Party Libraries
21.1. MonoTouch.Dialog
21.1.1. DialogViewController
21.1.2. RootElement, Sections, and Child Elements
21.1.2.1. Sections
21.1.2.2. Elements
21.1.3. Using MT.D
21.1.3.1. Creating the Element (Content) Tree Manually
21.1.3.2. Using the Object Binding Pattern
21.1.4. LINQ Support
21.2. MonoTouch-Facebook
21.3. Three20
21.4. Tapku
21.5. MonoTouch-Controls
21.6. XNATouch
21.7. Summary
22. Using Objective-C Libraries and Code
22.1. btouch
22.1.1. btouch Process
22.2. A Quick Objective-C Primer
22.2.1. Files
22.2.2. Classes
22.2.3. Methods/Messages
22.2.3.1. Instance vs. Static
22.2.3.2. Invoking Methods
22.2.4. Properties
22.2.5. Protocols
22.2.5.1. Declaring Protocols
22.3. Compiling the Objective-C Library
22.3.1. Building the Tapku Library
22.3.1.1. Specifying the iOS SDK
22.3.1.2. Compiling
22.3.1.3. Combining Build Architectures with LIPO
22.3.2. Creating API Definition File and Helper Code
22.3.2.1. API Definition File
22.3.2.2. Additional Code
22.3.2.3. Wrapping Tapku
22.3.2.3.1. TKCoverflowCoverView
22.3.2.3.2. TKCoverflowDataSource
22.3.2.3.3. TKCoverflowViewDelegate
22.3.2.3.4. Finishing the TKCoverflowView Binding
22.3.2.4. Weak Delegate Pattern
22.3.2.5. Complete Tapku Coverflow Binding
22.3.3. Running btouch
22.3.4. Adding the Compiled Objective-C Library
22.3.5. Referencing the Wrapper DLL
22.3.6. Configuring the Build
22.3.7. Using the Library
22.4. Summary
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Copyright
Next
Next Chapter
About the Technical Reviewer
About the Author
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset