본문 바로가기

iOS 앱개발

(18)
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:..
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..
076 ~ 080. Accessory View, Self Sizing and Custom Cell Accessory View // // AccessoryViewController.swift // TableViewPractice // // Created by Martin.Q on 2021/09/07. // import UIKit class AccessoryViewController: UIViewController { @IBOutlet var accTable: UITableView! @IBAction func editAction(_ sender: Any) { accTable.setEditing(!accTable.isEditing, animated: true) } override func viewDidLoad() { super.viewDidLoad() } } extension AccessoryViewCon..
070 ~ 075. Table View, Multi Section, Separator and Table View Cell Table View TableView는 목록을 표시할 때 사용한다. TableView에는 Cell이 존재하고, 위의 화면엔 표시한 것을 포함해 9개의 Cell이 존재한다. Cell의 너비는 TableView의 너비와 같고, 따라서 수평으로 두 개의 Cell을 나란히 배치할 수 없다. 또한 스크롤 방향은 상하로 고정이다. 별도로 가로 스크롤을 설정할 수는 있지만, 해당 기능을 더 간편하게 구현할 수 있는 CollectionView를 더 많이 사용한다. Cell들이 모여있는 그룹을 Sction이라고 한다. TableView는 하나 이상의 Section을 가질 수 있고, 각각의 Section에는 Cell이 포함되지 않을 수 있다. TableView는 Sextion과 Cell을 2차원 배열로 관리한다. 따라서 ..
062 ~ 069. Handling Date Date 날짜를 처리하는 다양한 자료형이 존재한다. Class Strcture NSDate NSCalendar NSDateComponents NSTimeZone NSLocale Date Calendat DateComponents TimeZone Locale 예전엔 클래스로만 제공했지만 현행 코코아터치프레임워크는 구조체로도 제공하고 있다. 또한 이러한 자료형들은 클래스 자료형의 이름에서 NS를 제외한 이름을 가지고 있다. 이 둘은 이름과 구현 방식만 다를 뿐, 사용법과 동작 방식은 동일하거나 유사하고, 대부분의 자료형들이 브릿징을 지원하기때문에 타입캐스팅을 활용해 자유롭게 전환할 수 있다. Date() 결과 "Aug 27, 2021 at 12:47 PM" Date 생성자를 사용하면 위와 같은 날짜를 얻을 ..
053 ~ 061. Software Keyboard, Text Delegate, Input View & Input Accessory View and Password Auto Fill Software Keyboard 캘린더에서 Location을 선택하면 오른쪽의 화면으로 전환됨과 동시에, 키보드를 조작하면 검색 필드에 입력할 수 있게끔 동작한다. 다른 뷰로 포커스를 전환하거나 종료하기 전까지 이벤트를 처리하게 되는데 이를 First Responder라고 부른다. // // FirstResponderViewController.swift // HandlingText // // Created by Martin.Q on 2021/08/24. // import UIKit class FirstResponderViewController: UIViewController { @IBOutlet weak var textField: UITextField! @IBAction func startAction(_..
043 ~ 052. Label, Text Field, Text View and Text Input Label SingleLine Label 사용하는 씬의 구성은 위와 같다. Label의 속성들은 위와 같다. Text Plain를 선택하면 일반적인 텍스트를 사용한다. Attributed를 선택하면 문자열에 속성을 추가할 수 있다.(Attributed String에서 이어진다) Color 텍스트의 색을 설정한다. Background Color와 비교하기 위해 Foreground Color라고 부르기도 한다. Font 폰트의 크기와 종류, 스타일을 변경할 수 있다. Alignment 텍스트의 정렬 속성이다. 기본값은 Netural인데 언어 설정에 따라 글의 정렬이 달라진다. // // SingleLabelViewController.swift // HandlingText // // Created by Mar..