Upload
geoffrey-goetz
View
676
Download
0
Embed Size (px)
Citation preview
New to Native?Getting Started with iOS Development
@ggeoffreggeoffre.com
20 years of experience in the development, marketing, sales, and leadership of computer
software
A C T S
Before you do anything…
Search Google for…
“Apple Mobile HIG”
Apple’s Mobile Human Interface Guidelines
developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/
Popover
TableView
Using XcodeStep One - Get a Mac, any Mac
Step Two - Get Xcode
Download the free version of Xcode from the app store
Create a free developer account and download Xcodedeveloper.apple.com
Register your company and pay for a developer account to download Xcode betas
Creating a new project
Master Detail
Master Detail
Page Based
Page Based
Tabbed
Tabbed
Toolbar - Run, Stop, Show, Hide
Navigation - Project, Symbol, Find, Issue, Test, Debug, Breakpoint, Report
Editors - Source, Interface Builder, Project
Debugger - Stack Viewer, Output Console
Inspector/Library - File, Help, Code, Object, Media
The Basics of Xcode
The Basics of Xcode
The Basics of Xcode
The Basics of Xcode
Working with the UILabel
Drag and drop the object in IB onto the view
Working with the UILabel
Connect the object in IB to Code
Working with the UIButton
Drag and drop the object in IB onto the view
Working with the UIButton
Connect the object in IB to Code
Working with the UIButton
Create an action for the object
Working with the UITextView
Drag and drop the object in IB onto the view
Working with the UITextView
Connect the object in IB to Code
Working with the UITextView
Add the delegate interface to the View
Working with the UITextView
Set the objects delegate as the view
Working with the UITextView
Control the keyboard
//make the keyboard display
[textField becomeFirstResponder];
//make the keyboard hide
[textField resignFirstResponder];
Working with the UITextView
Implement optional delegate methods
//Dismiss the keyboard when the return key is tapped- (BOOL)textFieldShouldReturn:(UITextField *)textField { if (textField == self.someTextfield) { [textField resignFirstResponder]; return NO; } return YES;}
//Only allow numeric characters- (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)newString{ NSCharacterSet* notNumbers = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet]; NSUInteger location = [newString rangeOfCharacterFromSet:notNumbers].location; return ( location == NSNotFound );}
Managing Editing
textFieldShouldBeginEditing:
textFieldDidBeginEditing:
textFieldShouldEndEditing:
textFieldDidEndEditing:
Editing the Text Field’s Text
textField:shouldChangeCharactersInRange:replacementString:
textFieldShouldClear:
textFieldShouldReturn:
Working with the UITextView
Review: Working with the…
UILabel UIButton UITextField
Working with the UILabel
Drag and drop the object in IB onto the view
Connect the object in IB to Code
Working with the UIButton
Drag and drop the object in IB onto the view
Connect the object in IB to Code
Create an action for the object
Working with the UITextView
Drag and drop the object in IB onto the view
Connect the object in IB to Code
Add the delegate interface to the View
Set the objects delegate as the view
Implement optional delegate methods
Debugging in the Simulator
Managing Devices
Debugging in the Simulator
Reseting the Simulator
Debugging in the Simulator
Toggle, Run, Step Over, Step Into, Step Out
float someFloat = 1.2345;int someInteger = 6;NSString *someString = @"Seven";NSLog(@"Some Float: %f Some Integer: %i Some String: %@“ , someFloat, someInteger, someString);
Technical Note TN2347
Logging console messages
Debugging in the Simulator
Working with Colors
Use the Color Picker
To save yourcolor choices
Working with Colors
Add the UIKit Frameworkto your project
Working with Colors#import <Foundation/Foundation.h>#import <UIKit/UIKit.h>
@interface UIColor (My)
+(UIColor *) MyOffWhiteColor;
@end
@interface UIFont (My)
+(UIFont *) MyLightFontWithFontSize:(float)fontSize;
@end#import "MyColorsAndFonts.h"
@implementation UIColor (My)
+(UIColor *) MyOffWhiteColor { return [UIColor colorWithRed: 252.0/255.0 green: 251.0/255.0 blue: 247.0/255.0 alpha: 1.0]; };
@end
@implementation UIFont (My)
+(UIFont *) MyLightFontWithFontSize:(float)fontSize { return [UIFont fontWithName:@"HelveticaNeue-Light" size:fontSize]; }
@end
Create a customColor and Font
Class
Working with Colors
http://www.javascripter.net/faq/hextorgb.htm
Color Sync Utility
Digital Color Meter
Hex-to-RGB Conversion
Transitons Animations
Disable Auto Layouton the View
Working with the UILabel
Connect the object in IB to Code
Transitons Animations[UIView animateWithDuration:3.0 animations:^{
[self.someLabel setAlpha:1.0];
}];
Write Some Code
[UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:500.0f initialSpringVelocity:0.0f options:UIViewAnimationOptionCurveLinear animations:^{ [self.someLabel setAlpha:1.0];
}completion:^{
[self doSomething];
}];
[self.view setNeedsUpdateConstraints];[UIView animateWithDuration:3.0 animations:^{
[self.someLabel setAlpha:1.0];
[self.view layoutIfNeeded];}];
UIAlertView and its Delegate
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle: @"Some Title" message:@"Some Alert” delegate:self cancelButtonTitle:@“Cancel" otherButtonTitles:@"Ok", nil]; [alertView show];
Display an Alert
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex{
switch (buttonIndex) { case 0: NSLog(@"Cancel"); break; case 1: NSLog(@"OK"); break; default: break; }}
Respond to an Alert
Storyboards and Nibs (Xibs)
Nibs and Xibs are the same
“N” is for NeXt, “ib” is for Interface Builder
“X” is for XML, “ib” is for Interface Builder
One .xib file for one
Storyboards are like Xibs for multiple UIView Controllers
Creating a new Xib
Creating a new Storyboard
Binding in Interface Builder
Select the ViewController in Interface Builder
Navigate to the Identity Inspector
Set the Custom Class Name
Set the Storyboard ID
Storyboards and Nibs (Xibs)Creating a UIViewController from a Storyboard
Creating a UIViewController from a Nib (Xib)
SomeViewController* someViewController = [self.storyboard instantiateViewControllerWithIdentifier:@“SomeView"];
[[self navigationController] presentViewController:someViewController animated:YES completion:nil];
SomeViewController* someViewController = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
[[self navigationController] presentViewController:someViewController animated:YES completion:nil];
Multiple StoryboardsOne “Shared” Storyboard
Multiple Storyboards
SomeViewController* someViewController = [self.storyboard instantiateViewControllerWithIdentifier:@“SomeView"];
[[self navigationController] presentViewController:someViewController animated:YES completion:nil];
UIStoryboard *someStoryboard = [UIStoryboard storyboardWithName:@"SomeStoryboard" bundle:nil];
SomeViewController* someViewController = [someStoryboard instantiateViewControllerWithIdentifier:@“SomeView"];
[[self navigationController] presentViewController:someViewController animated:YES completion:nil];
Debugging on a deviceEnable Mac to be in “Development Mode”
Create Developer Account and Provisioning Profile
Add your device to your account (hard limit of 100 devices)
developer.apple.com
Provisioning Test Devices
Create a Provisioning Profile
Download and install Certificates
Build and Deploy Xcode Archives
Provisioning Test Devices
Tools
Xcode Organizer for iOS Devices and Profiles
ADC Development Provisioning Portal
ADC Development Provisioning Assistant
Certificates
WWDR Intermediate Certificate
Developer Certificate
Provisioning Profile Certificate
ADC iOS Provisioning Portal
Manually Manage Devices
Developers
Profiles
App IDs
Debugging on a device
Log on with your Apple ID to your Apple Developer
Account
Managing Devices
Debugging on a device
Attach the Device to your Mac
Debugging on a device
Check the Project Settings• Bundle Identifier• Team Provisioning Profile• Deployment Target
Select the Deviceand Run
Debugging on a device
airserver.com
airsquirrels.com
When Things Go Wrong...
Technical Note TN2250 - Understanding and Resolving Code Signing Issues
TestFlight Distribution
Setup a free TestFlight account and create a team.
Invite and gather the UDIDs from the team members.
Add devices to your ADC Provisioning Profile.
Build an .ipa archive in Xcode and upload to TestFlight.
Distribute the build and manage the feedback.
TestFlight Distribution