2013
Nguyn Anh Tip - Cao Thanh Vàng
Đại Hc Lc Hng
20/11/2013
Tài Liệu Hướng Dn Xây Dng
ng Dng iPhone
MC LC
CHƯƠNG I CHUẨN B TRƯC KHI BT ĐU XÂY DNG NG DNG ........... 1
1.1 CHUN B H ĐIU HÀNH MAC OS .................................................................... 2
1.1.1 Lp Trình ng Dng Iphone Trên Windows .................................................. 2
1.1.2 S Dng Sn Phm Chính Hãng Apple ............................................................ 3
1.1.3 Chy H Điu Hành Mac Os Trên Pc/Laptop Intel/Amd Ti Sao Không?
....................................................................................................................................... 5
1.2 PHN MM XCODE .................................................................................................. 7
1.2.1 Cài Đặt Thông Qua Bn Ti V T Trang Dành Cho Developer .................. 8
1.2.2 Cài Đặt Thông Qua Apple Mac Store ............................................................. 10
1.2.3 Cài Đặt T Bản Xcode Được Chia S Trên Internet .................................... 11
CHƯƠNG II TÌM HIU XCODE VÀ IOS SIMULATOR ......................................... 12
2.1 TÌM HIU XCODE 5 ................................................................................................ 13
2.1.1 Gii Thiu V Xcode 5 ..................................................................................... 13
2.1.2 Thao Tác To ng Dng Mi ......................................................................... 16
2.1.3 Tìm Hiu Giao Din Xcode Và Mt S Tính Năng ....................................... 20
2.1.4 Thiết Kế Giao Din ........................................................................................... 26
2.1.5 Viết Code ........................................................................................................... 29
2.1.6 Thc Thi Và Kim Tra Li Ca ng Dng ................................................... 34
2.2 TÌM HIU IOS SIMULATOR ................................................................................. 38
2.2.1 Gii Thiu iOS Simulator ................................................................................ 38
2.2.2 Tìm Hiu iOS Simulator .................................................................................. 38
CHƯƠNG III NGÔN NGỮ OBJECTIVE-C ................................................................ 48
3.1 GII THIU NGÔN NG OBJECTIVED-C ........................................................ 49
3.2 KHAI BÁO BIN - CÁCH S DNG ..................................................................... 49
3.2.1 Biến ..................................................................................................................... 49
3.2.2 Quy Tc Đt Tên ............................................................................................... 50
3.3 KIU D LIU .......................................................................................................... 50
3.4 PHÉP TOÁN ............................................................................................................... 51
3.5 CHÚ THÍCH CODE .................................................................................................. 51
3.6 XUT D LIU RA MÀN HÌNH ............................................................................ 52
3.7 FUNCTION ................................................................................................................. 54
3.7.1 Định Nghĩa ......................................................................................................... 54
3.7.2 Phương Thức Không Có Tham S Truyn Vào ........................................... 54
3.7.3 Phương Thức Có 1 Tham S Truyn Vào ...................................................... 55
3.7.4 Phương Thức Có Nhiu Tham S Truyn Vào.............................................. 55
3.8 CẤU TRÚC ĐIU KIN ........................................................................................... 57
3.8.1 Câu Lnh If ....................................................................................................... 57
3.8.2 Câu Lnh If Else ............................................................................................ 57
3.8.3 Câu Lnh Switch - Case ................................................................................... 58
3.9 Cu Trúc Lp .............................................................................................................. 59
3.9.1 Vòng Lp For .................................................................................................... 59
3.9.2 Vòng Lp While ................................................................................................ 59
3.9.3 Vòng Lp Do-While .......................................................................................... 60
3.10 MNG........................................................................................................................ 61
3.10.1 Định Nghĩa ....................................................................................................... 61
3.10.2 Mng Nsarray ................................................................................................. 61
3.11 CHUI ĐỐI TƯỢNG NSSTRING...................................................................... 62
3.11.1 Khi To Chui ............................................................................................... 62
3.11.2 Đối Tượng NSString ....................................................................................... 63
3.11.3 Tìm Kiếm Bên Trong Chui .......................................................................... 63
3.11.4 Tìm Chui Và Thay Nó Thành Chui Khác ................................................ 64
3.11.5 Xoá Ni Dung Bên Trong Chui ................................................................... 64
3.11.6 Ct Chui ......................................................................................................... 65
3.11.7 Chèn Ký T Vào Trong Chui ...................................................................... 66
3.11.8 Chèn Ký T Vào Cui Chui ........................................................................ 66
3.11.8 So Sánh Chui ................................................................................................. 67
3.11.9 So Sánh Chui Vi Ký T Đu Và Cui Chui ........................................... 67
3.11.10 Chuyn Đi Hình Dng Ca Ch................................................................ 68
3.11.11 Chuyn Chui Thành Dng S .................................................................... 70
CHƯƠNG IV MỘT S THAO TÁC CƠ BẢN ............................................................. 72
4.1 APP ICON LOADING SCREEN .......................................................................... 73
4.1.1 App Icon............................................................................................................. 73
4.1.2 Loading Screen .................................................................................................. 75
4.2 THAY ĐỔI APP NAME ............................................................................................ 76
4.3 N STATUS BAR ...................................................................................................... 78
4.4 BACKGROUND ......................................................................................................... 79
4.4.1 Background Image ............................................................................................ 79
4.4.2 Background Color ............................................................................................ 83
4.5 THÊM FRAMEWORK ............................................................................................. 84
CHƯƠNG V MỘT S ĐỐI TƯỢNG CƠ BẢN ............................................................ 86
5.1 ĐỐI TƯỢNG LABEL BUTTON TEXT FIELD ............................................... 87
5.1.1 Gii Thiu .......................................................................................................... 87
5.1.2 Ví D .................................................................................................................. 90
5.2 KT NỐI CƠ SỞ D LIU VI SQLITE ............................................................. 94
5.2.1 Gii Thiu .......................................................................................................... 94
5.2.2 Cài Đặt Sqlite Manager Cho Firefox .............................................................. 94
5.2.3 Cu Hình ng Dng Đ Tương Tác Với Sqlite ............................................. 95
5.2.4 Các Hàm Trong Sqlite ...................................................................................... 96
5.2.5 Ví D .................................................................................................................. 99
5.3 S DNG CAMERA IPHONE .............................................................................. 109
5.3.1 Gii Thiu ........................................................................................................ 109
5.3.2 Ví D ................................................................................................................ 109
5.4 UIIMAGE .................................................................................................................. 113
5.4.1 Gii Thiu ........................................................................................................ 113
5.4.2 Các Định Dng nh H Tr Trên Iphone ................................................... 114
5.4.3 Ví D ................................................................................................................ 114
5.5 UIALERT VIEW ...................................................................................................... 121
5.5.1 Gii Thiu ........................................................................................................ 121
5.5.2 Đặc Điểm .......................................................................................................... 121
5.5.3 Ví D ................................................................................................................ 122
5.6 UISLIDER ................................................................................................................. 124
5.6.1 Gii Thiu ........................................................................................................ 124
5.6.2 Đặc Điểm .......................................................................................................... 125
5.6.3 Ví D ................................................................................................................ 125
5.7 UIWEBVIEW ........................................................................................................... 128
5.7.1 Gii Thiu ........................................................................................................ 128
5.7.2 Ví D ................................................................................................................ 129
5.8 ACTIVITY INDICATOR VIEW ............................................................................ 132
5.8.1 Gii Thiu ........................................................................................................ 132
5.8.2 Ví D ................................................................................................................ 132
5.9 ACTIONSHEET ....................................................................................................... 136
5.9.1 Gii Thiu ........................................................................................................ 136
5.9.2 Đặc Điểm .......................................................................................................... 136
5.9.3 Ví D ................................................................................................................ 137
5.10 MK MAP VIEW ..................................................................................................... 138
5.10.1 Gii Thiu ...................................................................................................... 138
5.10.2 Ví D .............................................................................................................. 139
5.11 TABLE VIEW CONTROLLER ........................................................................... 143
5.11.1 Gii Thiu ...................................................................................................... 143
5.11.2 Ví D .............................................................................................................. 143
5.12 SEARCH BAR ........................................................................................................ 147
5.12.1 Gii Thiu ...................................................................................................... 147
5.12.2 Ví D .............................................................................................................. 148
5.13 TRUYN D LIU GIA CÁC VIEW .............................................................. 152
5.13.1 Gii Thiu ...................................................................................................... 152
5.13.2 Ví D .............................................................................................................. 152
CHƯƠNG VI HƯỚNG DN XÂY DNG PHN MM .......................................... 157