SeSAC_iOS_Day 15 | TIL
👩💻 カリキュラムと追加学習
📂 RawString
#
を付けることができます.var notice = #"온라인 라이브 수업은 "Zoom"으로 진행합니다."#
「Zoom」で行われている、勘定科目のオンライン・ライブ・レッスン.var notice = #"온라인 라이브 수업은 \Zoom\으로 진행합니다."#
オンライン生放送レッスンはZoomで行います.\
と文字の間に#
を追加するだけです.var notice = #"온라인 라이브 수업은 \#n\Zoom\으로 진행합니다."#
勘定科目のオンライン・ライブ・レッスン\Zoom\.
#
を追加する必要があります.var onlineService = "WhaleOn"
var notice = #"온라인 라이브 수업은 \#(onlineService)으로 진행합니다."#
勘定科目のオンライン・ライブ・レッスンはWhaleonで行います.📂 WKWebView & Search Bar
WebKit View
を使用できます.delegate
!searchBarSearchButtonClicked
UI SearchBarDelegteプロトコルで実装される方法の1つ|918;8|func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
// guard 문으로 searchBar에 입력된 문자열을 URL로 변경해주고 request 후 그 결과를 webView에 띄워준다.
guard let url = URL(string: searchBar.text ?? "") else {
print("ERROR")
return
}
let request = URLRequest(url: url)
webView.load(request)
}
📂 App Transport Security Settings
アプリケーションがサーバに送信するデータのセキュリティ設定
HTTPプロトコルを使用した外部サーバとの通信を設定
HTTPS(セキュリティ):パケットの暗号化と転送によりセキュリティを確保する
すべてのドメインに対してHTTP通信を許可する:安全性の面でこの方式を採用することを提案しない
📂 UICollectionView
1.CollectionView Outletへの接続
@IBOutlet var tagCollectionView: UICollectionView!
2. CollectionView Protocol: UICollectionViewDelegate, UICollectionViewDataSource
-コード
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 10
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// 이 코드 대신 tag 설정해두고 사용해도됨
return collectionView == tagCollectionView ? 10 : mainArray.count
}
row
をitem
に変更した以外は、コード構成はほぼ同じです.func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: TagCollectionViewCell.identifier, for: indexPath) as? TagCollectionViewCell else {
return UICollectionViewCell()
}
return cell
}
3.Delegte、データソース接続
tagCollectionView.delegate = self
tagCollectionView.dataSource = self
4.XIB登録
let secondNibName = UINib(nibName: TagCollectionViewCell.identifier, bundle: nil)
tagCollectionView.register(secondNibName, forCellWithReuseIdentifier: TagCollectionViewCell.identifier)
📂 UICollectionViewFlowLayout
上下左右の余白(垂直部分)+セルとセルの間隔+セル上下の余白
FlowLayout instrumsの作成
let layout = UICollectionViewFlowLayout()
itemSizeの設定
// 각 셀과 셀 사이의 간격 설정
let spacing: CGFloat = 20
// 3개의 열로 세팅하기 위해서 전체 폭에서 4개의 간격만큼 값을 빼줌
let width = UIScreen.main.bounds.width - (spacing * 4)
// 전체 폭을 3으로 나눈 값만큼 폭을 설정해주고 이에 비례하여 높이도 설정해줌
layout.itemSize = CGSize(width: width / 3, height: width / 3 * 1.2)
minimumLineSpacing
行と行の間の最小間隔の設定
layout.minimumLineSpacing = spacing
minimumInteritemSpacing
列と列の最小間隔の設定
layout.minimumInteritemSpacing = spacing
scrollDirection
スクロール方向を横または縦に設定できます
layout.scrollDirection = .vertical
sectionInset
コンテンツ領域内のマージン値を設定できます(この部分はスクロール可能領域とも考えられます).
layout.sectionInset = UIEdgeInsets(top: spacing, left: spacing, bottom: spacing, right: spacing)
応用Layout
mainCollectionView.collectionViewLayout = layout
Tag - AddTarget & ReloadRows
現在、ViewControllerには100個の値
false
MainArray配列があります.Heartボタンをクリックするたびに埋まったHeartと空のHeartが出てきます
まず配列を発表する.
var mainArray = Array(repeating: false, count: 100)
cellForItemAt
メソッドでは、indexPath値を使用して各セルのボタンにタグを追加できます.これにより、配列内の各インデックスの値とボタンを一致させることができます.let item = mainArray[indexPath.item]
let image = item == true ? UIImage(systemName: "heart.fill") : UIImage(systemName: "heart")
cell.heartButton.setImage(image, for: .normal)
cell.mainImageView.backgroundColor = .red
cell.heartButton.tag = indexPath.item
cell.heartButton.addTarget(self, action: #selector(heartButtonTapped(selectButton:)), for: .touchUpInside)
このボタンをクリックするたびに、このボタンが持つタグ値を使用して、配列内のインデックスの値を現在の逆の値に更新します.
reloadData()
を使用できますが、ある場所の値を更新するだけであればreloadItems(at:)
を使用できます.tableViewは、同じ機能のメソッドをreloadRows
と定義します.@objc func heartButtonTapped(selectButton: UIButton) {
mainArray[selectButton.tag] = !mainArray[selectButton.tag]
mainCollectionView.reloadItems(at: [IndexPath(item: selectButton.tag, section: 0)])
}
👩💻 Mission
Core Location
Meet the Location Button(WWDC21)
What's new in location(WWDC20)
What's New in Core Location(WWDC15)
Reference
この問題について(SeSAC_iOS_Day 15 | TIL), 我々は、より多くの情報をここで見つけました https://velog.io/@hope1053/SeSACiOSDay-15-TILテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol