Giter Site home page Giter Site logo

weatherbyoc's Introduction

基于地理位置的天气预报iOS APP

image ##关键技术点

  1. 通过CoreLocation获取当前设备的地理位置信息
  2. 通过AFNetworking获取openweathermap接口的天气信息

##整体思路

  1. 声明UI控件
  2. 引用CoreLocation.h头文件
  3. 声明CLLocationManager类型对象并实例化
  4. 通过- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0)方法实时获取当前地理位置信息
  5. 利用CocoaPods,将AFNetworking类库导入到项目中
  6. 引用AFNetworking.h头文件
  7. 声明AFHTTPRequestOperationManager类型对象并实例化
  8. 发起Get请求,请求地址为:http://api.openweathermap.org/data/2.5/weather ,另外还需要配置3个参数:lat、lon、cnt,发起的请求地址类似于:http://api.openweathermap.org/data/2.5/weather?lat=-37.8136&%20&lon=144.9631&cnt=1
  9. 解析返回JSON格式的数据,先提取出name和temperature,并显示,另外还需要提取出weather的id值
  10. 根据weather的id不同值,与项目中图片进行匹配,显示响应天气情况的图片,该id不同取值请参考:http://bugs.openweathermap.org/projects/api/wiki/Weather_Condition_Codes
  11. 最后是细微优化一下,增加一个加载进度条和页面背景图片

weatherbyoc's People

Contributors

zukangwang avatar

Stargazers

 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.