본문 바로가기

iOS App development

(57)
110 ~ 113. Navigation Controller, Navigation Item & Navigation Bar, Customizing Navigation Controller and Toolbar Navigation Controller Navigation Controller는 가장 광범위하게 사용하는 Controller로, iOS 설정 앱이 Navigation controler를 사용한 대표적이 예라고 할 수 있다. Navigation Controller에서 원하는 항목을 선택하면 새로운 화면이 오른쪽에서 왼쪽으로 전환된다. 이런 전환 효과를 Push라고 부른다. 좌측 상단의 돌아가기 버튼을 누르면 이전의 화면이 왼쪽에서 오른쪽으로 전환된다. 이런 전환 효과를 Pop이라고 부른다. Navigation Controller는 항상 Push와 pop으로 화면을 전환한다. Navigation Controller는 Container Controll View에 해당한다. 따라서 실제 컨텐츠를 표현하는 Chi..
108 ~ 109. Orientation, Rotation and Container View Controller Orientation and Rotation iOS는 홈버튼의 위치에 따라서 Device Orientation을 7가지로 구별한다. Portrait 홈버튼이 아래쪽에 위치하는 가장 기본적인 상태이다. Portrait Upside Down 홈버튼이 위쪽에 위치하는 상태이다. Landscape Left 홈버튼이 왼쪽에 위치하는 상태이다. Landscape Right 홈버튼이 오른쪽에 위치하는 상태이다. Face Up 홈버튼이 하늘을 향하는 상태이다. Face Down 홈버튼이 바닥을 향하는 상태이다. Unknown iOS가 Device Orientation을 인식할 수 없는 상태이다. Interface Orientation은 앱이 지원하는 논리적 Orientation이다. 기본적으로 아이패드는 모든 Orie..
105 ~ 107. View Controller, View Management and View Controller Life Cycle View Controller View Controller는 다음의 3가지 역할을 수행한다. 화면에 표시되는 View를 관리한다. 모든 View Controller는 하나의 Root View를 가진다. Root View는 UI를 표시할 Frame을 제공하고, View 계층을 관리한다. 따라서 화면을 구성하는 모든 View는 항상 Root View 아래에 존재한다. Root View에 접근할 때에는 view 속성을 사용한다. Root View 이하에 있는 View에 접근할 때에는 Outlet으로 연결하거나 View Tagging을 사용한다. View에서 발생하는 이벤트를 처리한다. 예를 들어 Button에서 발생한 이벤트는 Controller와 연결해 Action으로 처리한다. Table View의 Data..
103 ~ 104. Reordering Items, Cell Prefetching & Data Prefetching and Refresh Control Reordering Item Collection View는 별도의 편집 모드를 제공하지 않는다. 따라서 Table View와 같은 Reordering Control을 제공하지 않는다. 대신 Pan Gesture를 사용해 이를 구현한다. 셀을 이동시키는 기능과 애니메이션은 이미 구현되어있지만 이동시킬 셀과 Panning 제스처를 추적하는 부분은 직접 구현해야 한다. extension ...: UICollectionViewDataSource { } 먼저 Delegate 메소드를 현하고 Reordering 기능을 활성화시킨다. 해당하는 메소드는 UICollectionViewDataSource 프로토콜에 구현되어있다. 또 다른 방법은 Pan gestureRecognizer를 Collection View와 연결하..
101 ~ 102. Managing the Selection and Edit Rows and Section Managing the Selection // // ManagingSectionViewController.swift // CollectionViewPractice // // Created by Martin.Q on 2021/10/15. // import UIKit class ManagingSelectionViewController: UIViewController { lazy var list: [MaterialColorDataSource.Color] = {(0...2).map { _ in MaterialColorDataSource.generateSingleSectionData() }.reduce([], +) }() lazy var checkImage: UIImage? = UIImage(systemName:..
100. Supplementary View Supplementary View Collection View의 Headr와 Footer를 합쳐서 Supplementary View라고 부른다. Flow Layout에서는 섹션의 시작부분과 마지막 부분에 각각 표시된다. Layout 속성과 Delegate 패턴을 통해 크기를 설정할 수 있지만, 스크롤 방향에 따라 제약을 받는다. Vertical 너비가 Collection View의 너비로 고정되고 높이만 설정할 수 있다. Horizontal 높이가 Collection View의 높이로 고정되고, 너비만 설정할 수 있다. 단, Custom Layout을 직접 적용하면 크기와 위치를 자유롭게 지정할 수 있다. Supplementary View는 재사용 메커니즘을 사용한다. 따라서 필요할 때 Collectio..
097 ~ 099. Collection View, Flow Layout, Collection View Cell and Self Sizing Cell Collection View Collection View를 채용한 가장 좋은 예는 사진 앱이다. Collection은 각각의 Cell로 컨텐츠를 표기하고, Cell들을 묶어 제공할 수 있다. 각각의 그룹을 Section이라고 부른다. Section을 구분하는 Header와 Footer가 존재하며, 이들은 Collection에서 Supplimentary View라고 부른다. 아이패드의 시계 앱도 Collection View를 사용한다. Custom Layout을 통해 위와 같이 개성있는 UI를 구현할 수 있다. Collection View의 배경으로 사용되는 View를 Decoration View라고 부르며, 위의 사진에서는 세계지도가 이에 해당한다. Collection View는 Flow Layout을 ..
091 ~ 096. Reordering Cell, Prefetching API, Table View Controller and Static Cell. Reordering Cell 시계 앱의 편집 모드에서 오른쪽에 표시되는 버튼이다. 드래그를 통해 셀의 순서를 재정의 할 수 있다. // // ReorderingCellViewController.swift // TableViewPractice // // Created by Martin.Q on 2021/10/04. // import UIKit class ReorderingCellViewController: UIViewController { var list1 = [String]() var list2 = [String]() var list3 = ["iMac Pro", "iMac 5K", "Macbook Pro", "iPad Pro", "iPad", "iPad mini", "iPhone 8", "iPhone 8..
087 ~ 090. Edit Mode, Row Action and Swipe Action Edit Mode Edit Control 시계 앱에서 좌상단의 Edit을 터치하면 오른쪽의 편집 모드로 전환된다. 편집 모드에선 셀을 추가하거나 삭제할 수 있고, 순서를 변경할 수도 있다. 셀의 좌측엔 Edit Control이 표시되고, 지금처럼 삭제 버튼이 표시되거나 추가 버튼을 표시할 수 있다. 셀의 우측엔 Reorder Control이 표시되고, 해당 부분을 드래그 하여 원하는 순서로 변경할 수 있다. 편집 모드에서의 작업 종류는 메소드 구현에 의해 결정된다. 삭제 등의 기능을 구현하고자 한다면 연관된 delegate 메서드를 구현해야 하고, 구현하지 않는다면 해당 컨트롤이 표시되지 않는다. Swipe to Delete swipe 하여 표시할 수 있는 삭제 기능은 Swipe to delete라고 부..
081 ~ 086. Customizing Section, Section Index Title, Table Header View, Table Footer View and Managing Selection Customizing Section Custom Header // // CustomSectionViewController.swift // TableViewPractice // // Created by Martin.Q on 2021/09/09. // import UIKit class CustomSectionViewController: UIViewController { @IBOutlet weak var tableView: UITableView! let list = Region.generate() override func viewDidLoad() { super.viewDidLoad() } } extension CustomSectionViewController: UITableViewDataSource { fun..