deep dive xamarin.ios

81
Xamarin.IOS Ben Bishop [email protected]

Upload: benjamin-bishop

Post on 07-May-2015

806 views

Category:

Technology


0 download

DESCRIPTION

My presentation from St. Louis Days of .NET that covers the 20% of concepts that helps you get through the 80% of your iOS app development with Xamarin.IOS.

TRANSCRIPT

Page 1: Deep Dive Xamarin.iOS

A Deeper Dive into Xamarin.IOS

Ben [email protected]

Page 2: Deep Dive Xamarin.iOS
Page 3: Deep Dive Xamarin.iOS
Page 4: Deep Dive Xamarin.iOS

for code/slides...@benjamminstl

@rendrstl

Page 5: Deep Dive Xamarin.iOS

Who Am i?• My name is Ben Bishop (Twitter:

@benjamminstl)

• I grew up in a small rural town of Indiana

• Went to Purdue University

• Now lives in Saint Louis

• Been independent for 4+ years

• Worked at an agency for 5 years, 1 year at TMG

Page 6: Deep Dive Xamarin.iOS

my new companyhttp://rendr.io

Page 7: Deep Dive Xamarin.iOS

David ortinauhttp://xamarin.com/evolve/2013

Page 8: Deep Dive Xamarin.iOS

FLash

Away3D, AIR, AS3, RobotLegs, FlexUnit

Page 9: Deep Dive Xamarin.iOS

Native IOSXamarin.IOS, Facebook, Twitter, SQLite, C#, NUnit

Page 10: Deep Dive Xamarin.iOS

$1200+60 hours

Page 11: Deep Dive Xamarin.iOS

Native AndroidXamarin.Android, C#, Twitter, Facebook, SQLite

Page 12: Deep Dive Xamarin.iOS

HybridPhoneGap, HTML, CSS3, jQuery, Backbone,

RequireJS

Page 13: Deep Dive Xamarin.iOS

Mobile optimized WebjQuery, Backbone, CSS3, Ruby on Rails,

Moustache, JSON

Page 14: Deep Dive Xamarin.iOS

WHAT IS A XAMARIN?

“The best damn mobile team,building the best damn mobile platform.”

Page 15: Deep Dive Xamarin.iOS

What is Mono?• Mono 1.0 was released on June 30, 2004

• “The Mono runtime contains a code execution engine that translates ECMA CIL byte codes into native code and supports a number of processors: ARM, MIPS SPARC, PowerPC, S390 , x86, x86-64 and IA-64 for 64-bit modes.”

• Also has support for LLVM

• Runs on Linux, OSX, Windows, PS3, XBox 360, Wii

Page 16: Deep Dive Xamarin.iOS

How does Mono Work?“Xamarin compiles your app to a native binary, not cross-compiled, and not interpreted.”

Page 17: Deep Dive Xamarin.iOS

Code StructureBy only having to write core code once, more time

can be spent tuning the UI per platform.

Page 18: Deep Dive Xamarin.iOS

cross platform strategies

Page 19: Deep Dive Xamarin.iOS

must have componentsComponents that keep you from having to write

platform specific code.

Page 20: Deep Dive Xamarin.iOS

xamarin.mobileA component that helps abstract your code for

location, photos, and contacts across all platforms.

Page 21: Deep Dive Xamarin.iOS

Xamarin.SocialA component that helps abstract your code for

App.Net, Twitter, Facebook, and Flickr

Page 22: Deep Dive Xamarin.iOS

xamarin.authMakes OAuth suck less.

Page 23: Deep Dive Xamarin.iOS

DataRestSharp, SQLite.NET, and JSON.net help you

store and retrieve data for your app.

Page 24: Deep Dive Xamarin.iOS

Frameworks

https://github.com/MvvmCross/MvvmCross

https://github.com/benbishop/MonkeyArms

Page 25: Deep Dive Xamarin.iOS

interfaces are your friend

Page 26: Deep Dive Xamarin.iOS

iOS Implementation

Have your platform specific views implementthe interface.

Page 27: Deep Dive Xamarin.iOS

android implementation

Page 28: Deep Dive Xamarin.iOS

ios implementation

Page 29: Deep Dive Xamarin.iOS

android implementation

Page 30: Deep Dive Xamarin.iOS

Mediator/View Model

Your Mediator or ViewModel will have a reference to the View

Page 31: Deep Dive Xamarin.iOS

UI Logic

Page 32: Deep Dive Xamarin.iOS

Mock your views

Moq lets you mock your viewsfor Unit Tests.

Page 33: Deep Dive Xamarin.iOS

Unit Test UI Logic

Moq can raise events and verifyMethod invocation.

Page 34: Deep Dive Xamarin.iOS

Test runner

Page 35: Deep Dive Xamarin.iOS

Strings

https://gist.github.com/benbishop/6232751ResourceManager

Page 36: Deep Dive Xamarin.iOS

detect locale

Page 37: Deep Dive Xamarin.iOS

anatomy of an iOS app

Page 38: Deep Dive Xamarin.iOS

info.plist

Page 39: Deep Dive Xamarin.iOS

info.plist

Page 40: Deep Dive Xamarin.iOS

important

Need to specify 640x1136 Launch Image soiOS knows your app supports tall UI

Page 41: Deep Dive Xamarin.iOS

entitlements.plist

New for iOS7

Page 42: Deep Dive Xamarin.iOS

New to iOS7

Page 43: Deep Dive Xamarin.iOS

Main.CS

Entry point for your app

Page 44: Deep Dive Xamarin.iOS

AppDelegate.cs

Creates the UI Window and attachesa ViewController.

Page 45: Deep Dive Xamarin.iOS

ViewController

This is responsible for your screen.

Page 46: Deep Dive Xamarin.iOS

ViewController Lifecycle

Page 47: Deep Dive Xamarin.iOS

Setup/tear down

Great place to do any setup/tear down.

Page 48: Deep Dive Xamarin.iOS

View

Page 49: Deep Dive Xamarin.iOS

Creating a view

Page 50: Deep Dive Xamarin.iOS

UIBUTTON

Page 51: Deep Dive Xamarin.iOS

frame vs bounds

Frame A view's frame (CGRect) is the position of its rectangle in the superview's coordinate system. By default it starts at the top left.Bounds A view's bounds (CGRect) expresses a view rectangle in its own coordinate system.

Page 52: Deep Dive Xamarin.iOS

extend views

Page 53: Deep Dive Xamarin.iOS

class extensions

All UIView classes now have a CenterHorizontally method

Page 54: Deep Dive Xamarin.iOS

Images for multi DPI

Page 55: Deep Dive Xamarin.iOS

Text Input

Page 56: Deep Dive Xamarin.iOS

view event handling

Page 57: Deep Dive Xamarin.iOS

View Controller Types

UIViewController TabViewControllerUITableViewControll

erUINavigationControll

er

Page 58: Deep Dive Xamarin.iOS

UITabViewController

Page 59: Deep Dive Xamarin.iOS

Setting title/Icon

Page 60: Deep Dive Xamarin.iOS

Header buttons

Page 61: Deep Dive Xamarin.iOS

detecting ios7

Page 62: Deep Dive Xamarin.iOS

UITableViews

Page 63: Deep Dive Xamarin.iOS

UITableViews

Page 64: Deep Dive Xamarin.iOS

UITableviewsource

Page 65: Deep Dive Xamarin.iOS

UITableviewsource

Page 66: Deep Dive Xamarin.iOS

UITableviewCell

Page 67: Deep Dive Xamarin.iOS

uitableviewcell styles

Page 68: Deep Dive Xamarin.iOS

UIPickerView

Page 69: Deep Dive Xamarin.iOS

UIPickerView

Page 70: Deep Dive Xamarin.iOS

uipickerview source

Page 71: Deep Dive Xamarin.iOS

UIPICKERVIEWMODEL

Page 72: Deep Dive Xamarin.iOS

UIPickerviewModel

Page 73: Deep Dive Xamarin.iOS

UIPickerviewModel

Page 74: Deep Dive Xamarin.iOS

UIPickerviewmodel

Page 75: Deep Dive Xamarin.iOS

Dialog

http://docs.xamarin.com/guides/ios/user_interface/monotouch.dialog/

Page 76: Deep Dive Xamarin.iOS

Rapid UI dev

Page 77: Deep Dive Xamarin.iOS

JSON support

Page 78: Deep Dive Xamarin.iOS

Attributes

Let’s decorate!!

Page 79: Deep Dive Xamarin.iOS

parting thoughts

Page 80: Deep Dive Xamarin.iOS

experiences• iOS sandbox is limited. You are at Apple’s mercy

• Provisioning is a pain

• iOS SDK is very prescriptive in regards to look and feel

• Most things are genuinely easier in iOS than Android. Music player, sharing to FB/Twitter, selecting photos...

• Few device configurations to work with.

Page 81: Deep Dive Xamarin.iOS

Gracias