여러 설정 수정하기

Judy·2021년 6월 26일
0

1. 파이어스토어 필드 배열 값 변경


카테고리 값을 설정할 수 있게 하도록 파이어스토어에 category 컬렉션을 추가하여 읽고 수정할 수 있게 했다.
let washingtonRef = db.collection("cities").document("DC")

// Atomically add a new region to the "regions" array field.
washingtonRef.updateData([
    "regions": FieldValue.arrayUnion(["greater_virginia"])
])

// Atomically remove a region from the "regions" array field.
washingtonRef.updateData([
    "regions": FieldValue.arrayRemove(["east_coast"])
])



2. Tab Bar 숨기기


navigation으로 넘어간 추가나 상세정보 뷰에서는 tab bar 이동이 불가능하게 하고 싶었는데 숨기고 싶은 뷰에서 Hide Bottom Bar on push 를 선택해주면 된다.!



3. 마커 클릭

Google Map에서 마커나 마커 정보뷰를 클릭했을 때 이벤트 설정

  1. GMSMapViewDelegate 델리게이트
class MapViewController: UIViewController, CLLocationManagerDelegate, GMSMapViewDelegate

2. viewDidLoad()에서 델리게이트 위임

mapView?.delegate = self


3.1 마커 정보 클릭 이벤트

    func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {
        code
    }

3.2 마커 클릭 이벤트
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
         code
         return true
   }

PerformSegue

마커 클릭으로 데이터를 다른 뷰에 넘기기 애매했는데 Segue로 넘길 수 있는 방법 발견

ViewController에서 ViewController로 Segue를 연결한 뒤 segue identifier에 이름을 부여하고

self.performSegue(withIdentifier: "sgMapInfo", sender: self)

performSegue를 부르면 segue를 트리거할 수 있다.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
        if segue.identifier == "sgMapInfo"{
            let infoView = segue.destination as! PlaceInfoTableViewController
            let i = places.first(where: {$0.name == placeTitle})
            infoView.getInfo(i!, image: placeImages[(i?.name!)!]!)
        }
    }
profile
iOS Developer

0개의 댓글