Giter Club home page Giter Club logo

wanted-pre-onboarding-ios's Introduction

wanted-pre-onboarding-iOS

날씨 정보 APP

제약 사항

  • 외부 라이브러리 사용 불가
    • Alamofire, Moya, Kingfisher 등 통신 관련 라이브러리도 사용 불가
    • SnapKit 사용 불가
  • 모든 화면은 오토레이아웃을 사용하여 레이아웃
    • UIKit 기반으로 UI를 구현하며, SwiftUI는 사용할 수 없습니다.
  • Open Weather의 API를 활용

앱 디자인 (Figma)

Screen Shot 2022-09-14 at 16 42 01



앱 실행 및 첫 번째 화면

MainViewController.swift

  • 뷰가 처음 로드되면 WeatherManager에서 API Request를 날려 날씨 정보를 Fetch -> Update 합니다.
  • CollectionView를 사용하여 각 도시 정보를 2열로 표현했습니다.
  • MVC 패턴을 적용했습니다.

mainVC



두 번째 화면

DetailWeatherViewController.swift

  • 메인에서 선택한 도시의 상세 날씨 정보를 StackView를 사용하여 표현했습니다.
  • 날씨 아이콘 이미지는 NSCache를 사용하여 캐싱했습니다.

detailVC



날씨 새로고침

  • RefreshControl을 사용하여 pull to refresh 기능을 구현했습니다.
  • Refresh가 시작되면 기존 날씨 데이터를 지우고 WeatherManager에서 새로운 날씨 정보를 받아옵니다.



이슈

CollectionView Cell 내부 뷰가 중첩되는 현상

issue1

  • 원인은 WeatherCollectionViewCell.swift에 있는 initViews() 함수였습니다.
  • 이 함수는 셀을 구성하는 뷰들을 생성하고 오토레이아웃을 적용하는 함수입니다.
  • 그래서 셀이 재활용될 때마다 이 함수가 수행되면 뷰들이 계속 생성되기 때문에 중첩되는 것이었습니다.
  • 따라서 셀이 처음 초기화될 때만 실행하도록 하여 해결했습니다.

날씨 데이터 업데이트 시 에러

  • WeatherManager에서 가져온 날씨 정보를 추가하고 collectionView.reloadData()로 반영할 때 This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes. 라는 에러가 발생했습니다.
  • UI를 Update할 때 메인 스레드에 넣지 않아 발생한 에러로 DispatchQueue.main.async{ }안에 넣어 해결했습니다.

wanted-pre-onboarding-ios's People

Contributors

skyqnaqna avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.