(31 july 2013) ios basic development day 2 human interface design

64
iOS Basic Development Day 2 Human Interface Design by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111 Wednesday, July 31, 13

Upload: eakapong-kattiya

Post on 15-Jan-2015

1.776 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: (31 July 2013) iOS Basic Development Day 2 Human interface design

iOS Basic Development

Day 2

Human Interface Design

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 2: (31 July 2013) iOS Basic Development Day 2 Human interface design

Slidewww.slideshare.net/eakkattiya

Source Codewww.ibluecode.com/training.html

Fan Pagewww.ios-talk.com

twitter.com/eakkattiya facebook.com/eakapong.kattiya

email : [email protected]

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111

Eakapong Kattiya

Professional Mobile Application Developer / TraineriOS & Android Platform

About

Wednesday, July 31, 13

Page 3: (31 July 2013) iOS Basic Development Day 2 Human interface design

Course Outline

1. Introduction Xcode & Language

2. Human Interface Design

3. UITableViewController & Datasource

4. Multimedia

5. Submit App Store

Course Outline

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 4: (31 July 2013) iOS Basic Development Day 2 Human interface design

Developing iOS Apps : Human Interface Design

• Focus on the primary task.• Make usage easy and obvious.• Use user-centric terminology.• Make targets fingertip-size.• De-emphasize settings.• Use user interface (UI) elements consistently.• Use subtle animation to communicate.• Ask people to save only when necessary.

http://tinyurl.com/3de5ow8

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 5: (31 July 2013) iOS Basic Development Day 2 Human interface design

Organizing Content

- ผใชสวนใหญจะเขาโปรแกรมเพอเรยกขอมลหรอทางานสน ๆ แลวกจะออกจากโปรแกรม แตจะมการเขาใชงานบอย

- ไมทางานหลายอยางพรอมกนตอการกดปมของผใช 1 ครง

- เนนการแสดงขอมลของผใชเปนหลก

- ไมใชการนาเอา Desktop มายอขนาดหนาจอ

Wednesday, July 31, 13

Page 6: (31 July 2013) iOS Basic Development Day 2 Human interface design

Developing iOS Apps : App Design

• ]

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 7: (31 July 2013) iOS Basic Development Day 2 Human interface design

UITabBarController & UINavigationBarController

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 8: (31 July 2013) iOS Basic Development Day 2 Human interface design

UITabBarController

ทาหนาทสลบ ViewController หลาย ๆ ตวไปมาUITabBarItem ปมของ UITabBar สามารถแกไขได

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 9: (31 July 2013) iOS Basic Development Day 2 Human interface design

ใชสาหรบแสดง ViewController เปนลาดบชนไปเรอย ๆ โดยสามารถยอนกลบด ViewController กอนหนาได

UINavigationController

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 10: (31 July 2013) iOS Basic Development Day 2 Human interface design

BECTeroradio

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 11: (31 July 2013) iOS Basic Development Day 2 Human interface design

Thailand YellowPages

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 12: (31 July 2013) iOS Basic Development Day 2 Human interface design

Thai M Service

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 13: (31 July 2013) iOS Basic Development Day 2 Human interface design

Assumption University

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 14: (31 July 2013) iOS Basic Development Day 2 Human interface design

HIPKINGDOM

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 15: (31 July 2013) iOS Basic Development Day 2 Human interface design

http://www.apple.com/ios/videos/#developers

http://pitchenvy.com

http://thumbsup.in.th

Idea for new app ?

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 16: (31 July 2013) iOS Basic Development Day 2 Human interface design

UINavigationController

- pushViewController ใชสาหรบเพม ViewController เขาไปใน UINavigationController

- popViewController ใชสาหรบลบ ViewController ออกจาก UINavigationController

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 17: (31 July 2013) iOS Basic Development Day 2 Human interface design

UINavigationItem

.rightBarButtonItem.leftBarButtonItem

.title

Wednesday, July 31, 13

Page 18: (31 July 2013) iOS Basic Development Day 2 Human interface design

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111

Create Tabbed Application

Wednesday, July 31, 13

Page 19: (31 July 2013) iOS Basic Development Day 2 Human interface design

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111

Create Tabbed Application : ShowCase

Wednesday, July 31, 13

Page 20: (31 July 2013) iOS Basic Development Day 2 Human interface design

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111

Choose Project Folder

Wednesday, July 31, 13

Page 21: (31 July 2013) iOS Basic Development Day 2 Human interface design

Storyboard : Select MainStoryboard_iPhone.storyboard

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 22: (31 July 2013) iOS Basic Development Day 2 Human interface design

Storyboard : Embed in Navigation Controller (First View)

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 23: (31 July 2013) iOS Basic Development Day 2 Human interface design

Storyboard : First Tab Bar with Navigation Controller

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 24: (31 July 2013) iOS Basic Development Day 2 Human interface design

Storyboard : Embed In Navigation Controller (Second View)

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 25: (31 July 2013) iOS Basic Development Day 2 Human interface design

Storyboard : Second Tab Bar with Navigation Controller

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 26: (31 July 2013) iOS Basic Development Day 2 Human interface design

Shared Application

เปด Application ใน iPhone เชน โทรศพท สงขอความ สงอเมล safari google map youTube

Local File

เลนไฟลจากใน Bundle ของ Application เอง

Remote File

เลนไฟลจากบน Server

Http Live Streaming

เลนไฟลจากบน Server แบบ Streaming

* ตองเปนแบบ Http Live Streaming เทานน ไมสามารถใช RSTP หรอ Flash Streaming ได

NSURL

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 27: (31 July 2013) iOS Basic Development Day 2 Human interface design

NSURL *url = [NSURL URLWithString:@"tel:0866732111"];

TEL

NSURL *url = [NSURL URLWithString:@"sms:0866732111"];

SMS

NSURL *url = [NSURL URLWithString:@"mailto:[email protected]"];

MAILTO

[[UIApplication sharedApplication] openURL:url];

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 29: (31 July 2013) iOS Basic Development Day 2 Human interface design

NSURL *url = [NSURL URLWithString:@"http://www.youtube.com/watch?v=OGZe27ZBajE" ;

[[UIApplication sharedApplication] openURL:url];

YouTube

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 30: (31 July 2013) iOS Basic Development Day 2 Human interface design

Local File

NSURL *plistURL = [[NSBundle mainBundle] URLForResource:@"table" withExtension:@"plist"];

NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"info" withExtension:@"pdf"];

NSURL *movieURL = [[NSBundle mainBundle] URLForResource:@"movie" withExtension:@"mp4"];

NSURL *musicURL = [[NSBundle mainBundle] URLForResource:@"music" withExtension:@"mp3"];

NSURL

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 32: (31 July 2013) iOS Basic Development Day 2 Human interface design

Http Live Streaming

NSString *liveStreaming = @"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"

NSURL *myURL = [NSURL URLWithString:liveStreaming];

NSURL

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 33: (31 July 2013) iOS Basic Development Day 2 Human interface design

UIWebView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 35: (31 July 2013) iOS Basic Development Day 2 Human interface design

Class : UIWebView

Framework : UIKit

Sample Code : TransWeb

Init : Interface Builder

Property : scalesPageToFit

Method : loadRequest: loadHTMLString:baseURL:

UIWebView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 36: (31 July 2013) iOS Basic Development Day 2 Human interface design

การเรยกใชงาน HTTP1. create UIWebView Outlet(Interface Builder)2. set Delegate3. create NSURL4. create NSURLRequest5. call loadRequest@implementation WebViewController

- (void)viewDidLoad{ [super viewDidLoad];

NSURL *wwwURL = [NSURL URLWithString:@"http://www.sanook.com"];

NSURLRequest *request = [[NSURLRequest alloc]initWithURL:wwwURL];

[myWebView loadRequest:request];}

UIWebView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 37: (31 July 2013) iOS Basic Development Day 2 Human interface design

การเรยกใชงาน PDF1. create UIWebView Outlet(Interface Builder)2. set Delegate3. create NSURL4. create NSURLRequest5. call loadRequest

@implementation WebViewController

- (void)viewDidLoad{ [super viewDidLoad];

NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"info" withExtension:@"pdf"];

NSURLRequest *request = [[NSURLRequest alloc]initWithURL:pdfURL];

[myWebView loadRequest:request];}

UIWebView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 38: (31 July 2013) iOS Basic Development Day 2 Human interface design

การเรยกใชงาน HTML1. create UIWebView Outlet(Interface Builder)2. set Delegate3. create HTML String4. call loadHTMLString: baseURL:

@implementation WebViewController

- (void)viewDidLoad{ [super viewDidLoad];

NSString *myHTML = @"<html><body><h1>Hello, world!</h1></body></html>";

[myWebView loadHTMLString:myHTML baseURL:nil];}

UIWebView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 39: (31 July 2013) iOS Basic Development Day 2 Human interface design

WorkshopMyWebView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 40: (31 July 2013) iOS Basic Development Day 2 Human interface design

Property List

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 41: (31 July 2013) iOS Basic Development Day 2 Human interface design

เปนวธทชวยใหเกบขอมล ขนาดเลก อยางงาย ในโครงสรางแบบ XML โดยรองรบชนดขอมล

■ Arrays■ Dictionaries■ Strings■ numbers■ dates■ raw data

• NSUserDefaults class ใชโครงสรางของ plist ในการเกบขอมลเชนกน

Property List

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 42: (31 July 2013) iOS Basic Development Day 2 Human interface design

■ ขนาดขอมลใหญกวา 300 KB

■ ตองการเกบขอมลแบบ Custom Type

■ ขอมลทซบซอน หลายชน

Property List

เมอไรทไมควรใช plist

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 43: (31 July 2013) iOS Basic Development Day 2 Human interface design

Property List : Root type NSArray , NSDictionary

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>Name</key> <string>John Doe</string> <key>Phones</key> <array> <string>408-974-0000</string> <string>503-333-5555</string> </array></dict></plist>

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 44: (31 July 2013) iOS Basic Development Day 2 Human interface design

Class : UIScrollView

Framework : UIKit

Sample Code : UICatalog

Init : initWithFrame : (CGRect) or Interface Builder

Property : CGSize contentSize float minimumZoomScale float maximumZoomScale BOOL pagingEnabled

Delegate : viewForZoomingInScrollView

UIScrollView

Wednesday, July 31, 13

Page 45: (31 July 2013) iOS Basic Development Day 2 Human interface design

UIScrollView Gallery

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 46: (31 July 2013) iOS Basic Development Day 2 Human interface design

การเรยกใชงาน

1. Init UIScrollView2. bind Delegate3. กาหนด contentSize:(CGSize)size 4. กาหนด minimumZoomScale / maximumZoomScale5. กาหนด pagingEnabled6. ใช Delegate Zoom viewForZoomingInScrollView

UIScrollView

Wednesday, July 31, 13

Page 47: (31 July 2013) iOS Basic Development Day 2 Human interface design

UIScrollView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 48: (31 July 2013) iOS Basic Development Day 2 Human interface design

-(void)initScrollView{ NSURL *url = [[NSBundle mainBundle] URLForResource:@"gallery" withExtension:@"plist"]; NSArray *items = [NSArray arrayWithContentsOfURL:url]; UIScrollView *scv = [[UIScrollView alloc]initWithFrame:self.view.frame]; [scv setContentSize:CGSizeMake(320*items.count, 320)]; [scv setPagingEnabled:YES]; [self.view addSubview:scv]; NSInteger i = 0; for(NSString *imageName in items){ UIImageView *imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:imageName]];

[imageView setFrame:CGRectMake(320*i, 0, 320, 320)]; [imageView setContentMode:UIViewContentModeScaleAspectFit]; [scv addSubview:imageView]; i++ ; }}

UIScrollView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 49: (31 July 2013) iOS Basic Development Day 2 Human interface design

UIAlertView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 50: (31 July 2013) iOS Basic Development Day 2 Human interface design

-(void)showAlertView:(NSString*)title{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:@"" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show];}

UIAlertView

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 51: (31 July 2013) iOS Basic Development Day 2 Human interface design

iOS Basic Development

User Selection Design

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 52: (31 July 2013) iOS Basic Development Day 2 Human interface design

Social Share

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 53: (31 July 2013) iOS Basic Development Day 2 Human interface design

UIActionSheet

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 54: (31 July 2013) iOS Basic Development Day 2 Human interface design

- (IBAction)shareSocial:(id)sender { UIActionSheet *action = [[UIActionSheet alloc]initWithTitle:@"Social Network" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Facebook",@"Twitter", @"Instagram",@"Email", nil]; [action showInView:self.view];

}

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ if(buttonIndex == 0){ [self directShareFacebook:nil]; } if(buttonIndex == 1){ [self directShareTwitter:nil]; } if(buttonIndex == 2){ [self directShareInstagram:nil]; } if(buttonIndex == 3){ [self directSendMail:nil]; }}

UIActionSheet

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 55: (31 July 2013) iOS Basic Development Day 2 Human interface design

Social Framework

Facebook

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 56: (31 July 2013) iOS Basic Development Day 2 Human interface design

- (IBAction)directShareFacebook:(id)sender {

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; [composeVC setInitialText:self.myTextView.text]; UIImage *image = self.myImageView.image; [composeVC addImage:image]; NSURL *url = [NSURL URLWithString:@"http://www.ibluecode.com"]; [composeVC addURL:url]; [self presentViewController:composeVC animated:YES completion:nil]; }}

SLComposeViewController : Facebook

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 57: (31 July 2013) iOS Basic Development Day 2 Human interface design

Social Framework

Twitter

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 58: (31 July 2013) iOS Basic Development Day 2 Human interface design

- (IBAction)directShareTwitter:(id)sender {

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [composeVC setInitialText:self.myTextView.text]; UIImage *image = self.myImageView.image; [composeVC addImage:image]; NSURL *url = [NSURL URLWithString:@"http://www.ibluecode.com"]; [composeVC addURL:url]; [self presentViewController:composeVC animated:YES completion:nil]; }}

SLComposeViewController : Twitter

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 59: (31 July 2013) iOS Basic Development Day 2 Human interface design

UIDocumentInteractionController

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 60: (31 July 2013) iOS Basic Development Day 2 Human interface design

- (IBAction)openDocumentAction:(id)sender {

NSURL *url = [[NSBundle mainBundle] URLForResource:@"mac_pro" withExtension:@"jpeg"];

self.docController = [UIDocumentInteractionController interactionControllerWithURL:url]; self.docController.delegate = self ; NSLog(@"uti: %@", [self.docController UTI]); [self.docController presentOptionsMenuFromRect:self.view.frame inView:self.view animated:YES]; }

UIDocumentInteractionController : All

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 61: (31 July 2013) iOS Basic Development Day 2 Human interface design

- (IBAction)directShareInstagram:(id)sender { NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.igo"]; NSData *imageData = UIImagePNGRepresentation(self.myImageView.image); [imageData writeToFile:savedImagePath atomically:YES]; NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath]; NSLog(@"%@",imageUrl); UIDocumentInteractionController *docController = [UIDocumentInteractionController new]; docController.delegate = self; docController.UTI = @"com.instagram.exclusivegram"; docController.URL = imageUrl; [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

}else{

[self showAlertView:@"Please install Instagram before share."]; }

}

UIDocumentInteractionController : Instagram

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 62: (31 July 2013) iOS Basic Development Day 2 Human interface design

MFMailComposeViewController

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 63: (31 July 2013) iOS Basic Development Day 2 Human interface design

- (IBAction)directSendMail:(id)sender {

if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailVC = [[MFMailComposeViewController alloc] init]; mailVC.mailComposeDelegate = self; [mailVC setSubject:@"Subject"]; NSArray *toRecipients = [NSArray arrayWithObjects: @"[email protected]", @"[email protected]", nil];

[mailVC setToRecipients:toRecipients]; UIImage *myImage = self.myImageView.image ; NSData *imageData = UIImagePNGRepresentation(myImage); [mailVC addAttachmentData:imageData mimeType:@"image/png" fileName:@"attachment"]; NSString *emailBody = self.myTextView.text; [mailVC setMessageBody:emailBody isHTML:NO]; //iOS 5 //[self presentModalViewController:mailer animated:YES]; //iOS 6 [self presentViewController:mailVC animated:YES completion:nil]; }}

MFMailComposeViewController

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13

Page 64: (31 July 2013) iOS Basic Development Day 2 Human interface design

Q & A

by Eakapong Kattiya www.ibluecode.com [email protected] +66 086-673-2111Wednesday, July 31, 13