CS193P - Lecture 11 · iPhone Application Development Text Input Presenting Content Modally...
Transcript of CS193P - Lecture 11 · iPhone Application Development Text Input Presenting Content Modally...
CS193P - Lecture 11iPhone Application Development
Text InputPresenting Content Modally
1Wednesday, February 10, 2010
Announcements
2Wednesday, February 10, 2010
Announcements• Paparazzi 3 assignment is due Wednesday 2/17
2Wednesday, February 10, 2010
Announcements• Paparazzi 3 assignment is due Wednesday 2/17• This Friday’s extra session will feature Evan Doll
2Wednesday, February 10, 2010
Today’s Topics• Threading Wrap-Up• iPhone Keyboards• Customizing Text Input• Presenting Content Modally
3Wednesday, February 10, 2010
Alternatives to Threading
4Wednesday, February 10, 2010
Alternatives to Threading• Asynchronous (nonblocking) functions
■ Specify target/action or delegate for callback■ NSURLConnection has synchronous and asynchronous variants
4Wednesday, February 10, 2010
Alternatives to Threading• Asynchronous (nonblocking) functions
■ Specify target/action or delegate for callback■ NSURLConnection has synchronous and asynchronous variants
• Timers■ One-shot or recurring■ Specify a callback method■ Managed by the run loop
4Wednesday, February 10, 2010
Alternatives to Threading• Asynchronous (nonblocking) functions
■ Specify target/action or delegate for callback■ NSURLConnection has synchronous and asynchronous variants
• Timers■ One-shot or recurring■ Specify a callback method■ Managed by the run loop
• Higher level constructs like operations
4Wednesday, February 10, 2010
NSOperation• Abstract superclass• Manages thread creation and lifecycle
• Encapsulate a unit of work in an object• Specify priorities and dependencies
5Wednesday, February 10, 2010
Creating an NSOperation Subclass
6Wednesday, February 10, 2010
Creating an NSOperation Subclass• Define a custom init method
- (id)initWithSomeObject:(id)someObject{
self = [super init];if (self) {
self.someObject = someObject;}return self;
}
6Wednesday, February 10, 2010
Creating an NSOperation Subclass• Define a custom init method
• Override -main method to do work
- (id)initWithSomeObject:(id)someObject{
self = [super init];if (self) {
self.someObject = someObject;}return self;
}
- (void)main{
[someObject doLotsOfTimeConsumingWork];}
6Wednesday, February 10, 2010
NSOperationQueue• Operations are typically scheduled by adding to a queue• Choose a maximum number of concurrent operations• Queue runs operations based on priority and dependencies
7Wednesday, February 10, 2010
Using an NSInvocationOperation• Concrete subclass of NSOperation• For lightweight tasks where creating a subclass is overkill
8Wednesday, February 10, 2010
Using an NSInvocationOperation• Concrete subclass of NSOperation• For lightweight tasks where creating a subclass is overkill
- (void)someAction:(id)sender{
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(doWork:) object:someObject];
[queue addObject:operation];
[operation release];}
8Wednesday, February 10, 2010
iPhone Keyboards
9Wednesday, February 10, 2010
Virtual keyboard Appears when needed
10Wednesday, February 10, 2010
Virtual keyboard Appears when needed
11Wednesday, February 10, 2010
12Wednesday, February 10, 2010
13Wednesday, February 10, 2010
Portrait and Landscape
13Wednesday, February 10, 2010
Simple selection modelText loupe/magnifier
14Wednesday, February 10, 2010
Many keyboard typesAdapted to task
15Wednesday, February 10, 2010
Many keyboard typesAdapted to task
16Wednesday, February 10, 2010
Many keyboard typesAdapted to task
17Wednesday, February 10, 2010
Many keyboard typesAdapted to task
18Wednesday, February 10, 2010
Many keyboard typesAdapted to task
19Wednesday, February 10, 2010
Many keyboard typesAdapted to task
20Wednesday, February 10, 2010
Single line editing
21Wednesday, February 10, 2010
Multi-line editing
22Wednesday, February 10, 2010
40Languages
23Wednesday, February 10, 2010
40Languages
Full dictionary support
23Wednesday, February 10, 2010
English
24Wednesday, February 10, 2010
French
25Wednesday, February 10, 2010
Russian
26Wednesday, February 10, 2010
Korean
27Wednesday, February 10, 2010
Japanese Romaji
28Wednesday, February 10, 2010
Japanese Kana
29Wednesday, February 10, 2010
Chinese Pinyin
30Wednesday, February 10, 2010
Chinese Handwriting
Simplified Traditional
31Wednesday, February 10, 2010
Customizing Text Input
32Wednesday, February 10, 2010
Text Containers
33Wednesday, February 10, 2010
Text Containers
DelegatesNotifications
Methods
34Wednesday, February 10, 2010
Text Containers
Text Input Traits
35Wednesday, February 10, 2010
Text Input Traits
ProtocolUITextFieldUITextView
36Wednesday, February 10, 2010
Text Input Traits
Autocapitalization
Autocorrection
Keyboard Type
Keyboard Appearance
Return Key Type
Return Key Autoenabling
Secure Text Entry
37Wednesday, February 10, 2010
URL KeyboardGo button
Text Input Traits
38Wednesday, February 10, 2010
Default KeyboardGoogle button
Text Input Traits
39Wednesday, February 10, 2010
Text ContainersText Input Traits
DelegatesNotifications
Methods
40Wednesday, February 10, 2010
Text Containers
41Wednesday, February 10, 2010
UITextField
Design time
42Wednesday, February 10, 2010
Design time
URL KeyboardGo button
UITextField
43Wednesday, February 10, 2010
Run time
URL KeyboardGo button
UITextField
44Wednesday, February 10, 2010
Become first responder
URL KeyboardGo button
UITextField
45Wednesday, February 10, 2010
Keyboard
Become first responder
URL KeyboardGo button
UITextField
45Wednesday, February 10, 2010
Keyboard
Become first responder
URL KeyboardGo button
UITextField
46Wednesday, February 10, 2010
Keyboard
Become first responder
URL KeyboardGo button
UITextField
46Wednesday, February 10, 2010
Keyboard
Keyboard adopts traits
URL KeyboardGo button
UITextFieldURL KeyboardGo button
47Wednesday, February 10, 2010
Keyboard
Keyboard adopts traits
URL KeyboardGo button
UITextFieldURL KeyboardGo button
47Wednesday, February 10, 2010
Text Containers
UITextField
UITextView
Web Forms
48Wednesday, February 10, 2010
Demo:Text Input
49Wednesday, February 10, 2010
Presenting Content Modally
50Wednesday, February 10, 2010
• For adding or picking data
Presenting Content Modally
51Wednesday, February 10, 2010
• For adding or picking data
Presenting Content Modally
51Wednesday, February 10, 2010
• For adding or picking data
Presenting Content Modally
51Wednesday, February 10, 2010
Presenting a View Controller
52Wednesday, February 10, 2010
Presenting a View Controller// Recipe list view controller- (void)showAddRecipe {
RecipeAddViewController *viewController = ...;[self presentModalViewController:viewController animated:YES];
}
52Wednesday, February 10, 2010
Presenting a View Controller// Recipe list view controller- (void)showAddRecipe {
RecipeAddViewController *viewController = ...;[self presentModalViewController:viewController animated:YES];
}
52Wednesday, February 10, 2010
Dismissing a View Controller
53Wednesday, February 10, 2010
Dismissing a View Controller// Recipe list view controller- (void)didAddRecipe {
[self dismissModalViewControllerAnimated:YES];}
53Wednesday, February 10, 2010
Dismissing a View Controller// Recipe list view controller- (void)didAddRecipe {
[self dismissModalViewControllerAnimated:YES];}
53Wednesday, February 10, 2010
Separate Navigation Stacks
54Wednesday, February 10, 2010
Separate Navigation Stacks
54Wednesday, February 10, 2010
Separate Navigation Stacks
54Wednesday, February 10, 2010
Separate Navigation Stacks
54Wednesday, February 10, 2010
Separate Navigation Stacks
54Wednesday, February 10, 2010
Dismissing a Modal View Controller
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller■ Tell the delegate when the presented controller is done
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller■ Tell the delegate when the presented controller is done■ The delegate makes the call to dismiss
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller■ Tell the delegate when the presented controller is done■ The delegate makes the call to dismiss
Parent Controller
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller■ Tell the delegate when the presented controller is done■ The delegate makes the call to dismiss
Parent Controller
Child Controller
Present
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller■ Tell the delegate when the presented controller is done■ The delegate makes the call to dismiss
Parent Controller
Child Controller
I’m done!
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller■ Tell the delegate when the presented controller is done■ The delegate makes the call to dismiss
Parent Controller
Child Controller
Dismiss
55Wednesday, February 10, 2010
Dismissing a Modal View Controller• Who should do it?• Best practice is for the same object to call present and dismiss
• Define delegate methods for the presented controller■ Tell the delegate when the presented controller is done■ The delegate makes the call to dismiss
Parent Controller
55Wednesday, February 10, 2010
Demo:Presenting Content Modally
56Wednesday, February 10, 2010
Questions?
57Wednesday, February 10, 2010