iOS Weather View

Weather View is an iOS library and control for interacting with Weather Underground's API, which gives you access to location-specific weather details. Get information such as temperature, wind chill, UV, heat index, sunrise and sunset times, precipitation, conditions icon and forecasts. This package includes full source code and a working demo. View Pricing
scroll down for more

UIWeatherView is used to get location-specific weather information with this iOS library for interacting with Weather Underground's API. You can use UIWeatherView to add the UIWeatherView, which will show weather details, such as those below, in your app.

A Weather Underground API plan is required to use this library. The free plan is limited to 500 calls a day, and 10 calls a minute.

Weather Details

  • Temperature (Fahrenheit and Centigrade)
  • Relative Humidity
  • Wind (Degrees, MPH, KPH, Gust)
  • Pressure (Millibars, Inches, Trend)
  • Dewpoint (Fahrenheit, Centigrade)
  • Heat Index (Fahrenheit, Centigrade)
  • Windchill (Fahrenheit, Centigrade)
  • Feels like (Fahrenheit, Centigrade)
  • Visibility (Miles, KM) 
  • Solar Radiation
  • UV
  • Precipitation (1 Hr Inches, 1 Hr Metric, Today Inches, Today Metric)
  • Weather conditions icon url
  • Forecast url
  • History url
  • Sunrise time
  • Sunset time
  • Moon Percent Illumination
  • Moon Age

Displaying Weather Details

UIWeatherView uses Wunderground Weather API because it's very mature and provides free, medium and heavy usage accounts depending on your needs. Before you can call the API, you must call initializeWeatherService API providing your Wunderground Weather API key and location delegate, if you desire to receive location updates. See example below.

UIWeatherView, provides factory methods for easily creating Weather Views:

  • showWeatherForAddress - Show weather details for a specific address e.g. Cooperstown, NY.
  • showWeatherForCurrrentAddress - Show weather details for your current location. 
  • showWeatherForCoordinate - Show weather details for a specific latitude and longitude location.

Each of these factory methods will create, add a UIWeatherView to your specified UIView and return the created UIWeatherView. Each UIWindowView has an instance method for customization such as title and address. You can also create the UIWindowView without adding it to your view.

UIWeatherView has many static helper methods for acquiring the desired weather details for your Weather View. You can use methods such as showWeatherForAddress to quickly create weather views and/or the helper methods to get specific details. You can use just the helper methods to get specific details, without UIWeather UIView subclass controls. That said, you need to call getLocationWeather before using a helper method as they use the returned dictionary.

UIWeatherView Helper API

  • getLocationWeather - Get a dictionary containing weather details.
  • getLocationTemperatureFromDict - Get location's temperature.
  • getLocationTemperatureFahrenheitFromDict - Get location's temperature in Fahrenheit.
  • getLocationTemperatureCentigradeFromDict - Get location's temperature in Centigrade
  • getLocationRelativeHumidityFromDict - Get location's relative humidity.
  • getLocationWindFromDict - Get location's wind.
  • getLocationWindDegreesFromDict - Get location's wind in degrees.
  • getLocationWindMphFromDict - Get location's wind in mph.
  • getLocationWindGustMphFromDict - Get location wind gust in MPH.
  • getLocationWindKphFromDict - Get location's wind in KPH.
  • getLocationWindGustKphFromDict - Get location's wind gust in KPH.
  • getLocationPressureMbFromDict - Get location's pressure in millibars.
  • getLocationPressureInchesFromDict - Get location's pressure in inches.
  • getLocationPressureTrendFromDict - Get location's pressure trend.
  • getLocationDewpointFromDict - Get location's dew point.
  • getLocationDewpointFahrenheitFromDict - Get location's dew point in Fahrenheit.
  • getLocationDewpointCentigradeFromDict - Get location's dew point in Centigrade.
  • getLocationHeatIndexFromDict - Get location's heat index.
  • getLocationHeatIndexFahrenheitFromDict - Get location's heat index in Fahrenheit.
  • getLocationHeatIndexCentigradeFromDict - Get location's heat index in Centigrade.
  • getLocationWindchillFromDict - Get location's windchill.
  • getLocationWindchillFahrenheitFromDict - Get location's windchill in Fahrenheit.
  • getLocationWindchillCentigradeFromDict - Get location's windchill in Centigrade
  • getLocationFeelslikeFromDict - Get location's "feels like" temperature.
  • getLocationFeelslikeFahrenheitFromDict - Get location's "feels like" temperature in Fahrenheit
  • getLocationFeelslikeCentigradeFromDict - Get location's "feels like" temperature in Centigrade
  • getLocationVisibilityMilesFromDict - Get location's visibility in miles.
  • getLocationVisibilityKmFromDict - Get location's visibility in KM.
  • getLocationSolarRadiationFromDict - Get location's solar radiation.
  • getLocationUVFromDict - Get location's UV.
  • getLocationPrecipitation1HrFromDict - Get location's precipitation in last hour.
  • getLocationPrecipitation1HrInchesFromDict - Get location's precipitation in last hour in inches.
  • getLocationPrecipitation1HrMetricFromDict - Get location's precipitation in last hour in metric.
  • getLocationPrecipitationTodayFromDict - Get location's precipitation today.
  • getLocationPrecipitationTodayInchesFromDict - Get location's precipitation today in inches.
  • getLocationPrecipitationTodayMetricFromDict - Get location's precipitation today in metric.
  • getLocationIconFromDict - Get location's icon.
  • getLocationIconUrlFromDict - Get location's icon URL.
  • getLocationForecastUrlFromDict - Get location's forecast URL.
  • getLocationHistoryUrlFromDict - Get location's history URL.
  • getLocationSunriseFromDict - Get location's sunrise time.
  • getLocationSunsetFromDict - Get location's sunset time.
  • getLocationMoonPercentIllumnatedFromDict - Get location's moon percent illuminated.
  • getLocationMoonAgeFromDict - Get location's moon age.

UIWeatherView instance methods

  • setTitle - Set the title for the weather view.
  • setAddress - Set the address for the weather view and optionally refresh weather details.
  • showWeatherForecast - Show the weather forecast for the current weather.
  • shareWeather - Share the weather details.
  • resizeView - Resize the weather view.
  • closeView - Close the weather view.
  • isRunningIPad - See if running on iPad.

UIWeatherView location methods

Location monitoring is on by default. When monitoring is on, UIWindowView will keep track of your current address and optionally call your delegate if you want to be notified.

  • setLocationDelegate - Sets who receives location change notifications. Can also set on initializeWeatherService.
  • getAddressForCoordinate - Get the address for a latitude and longitude pair.
  • getAddressCoordinate - Get an address' latitude and longitude.
  • getFullAddressForAddress - Get the filled out and formatted address using the supplied address portion.
  • getCurrentAddress - Get the current address.
  • getCurrentCityStateAddress - Get the current address, but only the city and state.
  • getCurrentHeading - Get the current heading.
  • getCurrentHeadingAccuracy - Get the current heading accuracy.

Installation

To install UIWeatherView into your app, drag the files in the UIWeatherView folder into your project. Make sure that you indicate copy the files into your project. Also make sure that the Target Membership is checked for all the .m, .png and .jpg images.

UIWeatherView uses the Weather Underground Weather API, and the demo app uses the free Stratus Plan for Developers to get you started quickly. You can use this plan which is limited to 500 calls a day and 10 calls a minute. You should register at Wunderground.com for your own free or priced plan and configure you app to use your Wunderground account. See the demo app or code examples below and replace WUNDERGROUND_WEATHERAPI_KEY with your Wunderground Weather API key.

Required Frameworks and Libraries

The following frameworks must be included: Foundation, UIKit, CoreFoundation, CoreGraphics, CoreLocation, CoreText, MessageUI, MobileCoreServices, Security and SystemConfiguration.

Example Project Demo

The package zip also contains an Examples/Demo folder with a working demonstration of using UIWeatherView called "UIWeatherViewDemo". Open the xcodeproj file in Xcode to build and run the demo.

See our iMapMe iOS app on Apple AppStore as a good example of using iOS Weather View.

Note: The demo use a free Wunderground Stratus Plan (500 calls a day, 10 calls a minute, analytics) for developers.

iOS Support

This project supports iOS 7, iOS 8, iOS 9 and iOS 10.

Code examples

  // Register at Wunderground.com and then replace WUNDERGROUND_WEATHERAPI_KEY
// This demo's key uses the free plan which allows a usage of 500 calls per day
// and 10 calls a minute plus analytics.
#define WUNDERGROUND_WEATHERAPI_KEY @"c1bab46d564bdb9a"

CGRect rect = [[UIScreen mainScreen] bounds]; screenWidth = rect.size.width; screenHeight = rect.size.height; // UIWeatherView has about 50 APIs for doing weather, address and // latitude/longitude related functionality // plus location monitoring. // Create views and acquire data using APIs // // // Step 1. Initialize the weather service with your Wundergrounnd API Key // // initialize weather service using your Wunderground API Key // // see http://www.wunderground.com/weather/api for Wunderground API setup // Once setup you will find key in Key Settings tab // Weather API key (e.g. Wunderground Weather API Key ID) // // Register at Wunderground.com and then replace WUNDERGROUND_WEATHERAPI_KEY above // This demo's key uses the free plan which allows a usage of 500 calls per day and 10 calls a minute // // locationDelegate - is self, since we wan app to receive any location changes. // see didUpdateToLocation: and currentAddressChanged: callbacks below // [UIWeatherView initializeWeatherService:WUNDERGROUND_WEATHERAPI_KEY locationDelegate:self verbose:TRUE]; //[UIWeatherView setLocationMonitoring:TRUE]; // turn location monitoring ON (on by default) //[UIWeatherView setLocationMonitoring:FALSE]; // turn location monitor OFF (will effect current address APIs!) // address format is {city, state}. One comma separating city and state (2 letter abbrev e.g. NY, CA, VA) // some examples: // // Note: if location monitoring on and you receive currentAddressChanged: and other callbacks, the // current full address and city, state for current address is returned // //NSString * address = @"Cooperstown, NY 13326"; //NSString * address = @"7514 Cannon Fort Dr Clifton, VA 20124-2804 United States"; //NSString * address = @"San Francisco, CA"; NSString * address = @"Los Angeles, CA"; // Step 2. Use show APIs to display a weather view containing weather detail for a location // // 3 example of creating a weather view showing weather details for a location. // Show by address, current address and location latitude/longitude. // int width = screenWidth * .90; int height = screenHeight * .80; int x = (screenWidth - width) / 2; int y = (screenHeight - height) / 2; // Example 1: // show weather details for the address. Use City, State for the address e.g. 'Los Angeles, CA', 'Clifton, VA' // // title is shown at top of weather view // parent is parent view controller to add the weather view to // if nil will not add to any view just create and sharing is disabled // allowSharing adds a share button to share the weather details displayed // allowClosing adds a close button to close the view, if required // // returns UIWeatherView * - created weather view UIWeatherView * weatherView1 = [UIWeatherView showWeatherForAddress:address frame:CGRectMake(x, y, width, height) title:@"Weather" parent:self allowSharing:TRUE allowClosing:FALSE verbose:FALSE]; //[weatherView1 setTitle:@"New Weather"]; //[weatherView1 setAddress:@"San Francisco, CA" displayAddress:nil refreshDetails:TRUE verbose:FALSE]; //Example 2: (uncomment to try out. Be sure to comment out other examples since uses same area) // // show weather details for current address and wait for current address to be found... // // title is shown at top of weather view // allowSharing adds a share button to share the weather details displayed // allowClosing adds a close button to close the view, if required // waitForAddress waits for the current address to be found. // location monitoring must be on for this to work. By default location monitoring is on. // see above initializeWeatherService and setLocationMonitoring APIs // // returns UIWeatherView * - created weather view /** UIWeatherView * weatherView2 = [UIWeatherView showWeatherForCurrentAddress:CGRectMake(x, y, width, height) title:@"Weather Current" parent:self allowSharing:TRUE allowClosing:FALSE waitForAddress:TRUE verbose:FALSE]; **/ // Example 3: (uncomment to try out. Be sure to comment out other examples since uses same area) // // show weather for a coordinate (latitude and longitude) for San Francisco, CA... // // title is shown at top of weather view // allowSharing adds a share button to share the weather details displayed // allowClosing adds a close button to close the view, if required // // returns UIWeatherView * - created weather view /** CLLocationDegrees lat = 37.7749295; CLLocationDegrees lng = -122.4194155; CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(lat, lng); NSString * weatherTitle = [NSString stringWithFormat:@"Weather for %.2f, %.2f", lat, lng]; UIWeatherView * weatherView3 = [UIWeatherView showWeatherForCoordinate:coordinate frame:CGRectMake(x, y, width, height) title:weatherTitle parent:self allowSharing:TRUE allowClosing:FALSE verbose:FALSE]; **/ // Step 3. Use weather API to get tons of weather details // // get weather details for use in your own app... // // get the location weather... // all the main details for the weather. Does not include sunset, sunrise, moon illumination and age of moon. NSMutableDictionary * weatherDict = [UIWeatherView getLocationWeather:address verbose:FALSE]; NSString * weatherCondition = nil; NSString * temperature = nil; NSString * temp_f = nil; NSString * temp_c = nil; NSString * relativeHumidity = nil; NSString * forecastUrl = nil; NSString * historyUrl = nil; if (weatherDict != nil) { // // use helper APIs to get values... // weatherCondition = [UIWeatherView getLocationWeatherFromDict:weatherDict]; temperature = [UIWeatherView getLocationTemperatureFromDict:weatherDict]; temp_f = [UIWeatherView getLocationTemperatureFahrenheitFromDict:weatherDict]; temp_c = [UIWeatherView getLocationTemperatureCentigradeFromDict:weatherDict]; relativeHumidity = [UIWeatherView getLocationRelativeHumidityFromDict:weatherDict]; forecastUrl = [UIWeatherView getLocationForecastUrlFromDict:weatherDict]; historyUrl = [UIWeatherView getLocationHistoryUrlFromDict:weatherDict]; NSLog(@"Weather Conditions: %@", weatherCondition); NSLog(@"Temperature: %@", temperature); NSLog(@"Temperature (fahrenheit): %@", temp_f); NSLog(@"Temperature (centigrade): %@", temp_c); NSLog(@"Relative Humidity: %@", relativeHumidity); NSLog(@"Forecast url: %@", forecastUrl); NSLog(@"History url: %@", historyUrl); } NSString * weatherTemperature = [UIWeatherView getLocationTemperature:address verbose:FALSE]; NSLog(@"Temperature for %@ is %@", address, weatherTemperature); // get additional information for the location: // sunrise and sunset, // plus moon illumination and age of moon information // NSMutableDictionary * sunriseSunsetDict = [UIWeatherView getLocationSunriseSunset:address verbose:FALSE]; NSString * weatherSunrise = nil; NSString * weatherSunset = nil; NSString * weatherPercentIlluminated = nil; NSString * weatherAgeOfMoon = nil; if (sunriseSunsetDict != nil) { // // use helper APIs to get values... // weatherSunrise = [UIWeatherView getLocationSunriseFromDict:sunriseSunsetDict]; weatherSunset = [UIWeatherView getLocationSunsetFromDict:sunriseSunsetDict]; weatherPercentIlluminated = [UIWeatherView getLocationMoonPercentIllumnatedFromDict:sunriseSunsetDict]; weatherAgeOfMoon = [UIWeatherView getLocationMoonAgeFromDict:sunriseSunsetDict]; NSLog(@"Sunrise time: %@", weatherSunrise); NSLog(@"Sunset time: %@", weatherSunset); NSLog(@"Moon percent illuminated: %@", weatherPercentIlluminated); NSLog(@"Age of moon: %@", weatherAgeOfMoon); } } // Location address changed… // // if a locationDelegate is set on initializeWeatherService API call and location monitoring is on (by default is on) // // called if location monitoring is on // // provides: new current address, old address (if any) and city/state for new address (useful for showWeatherFor… APIs… // - (void)currentAddressChanged:(CLLocation *)currentLocation currentAddress:(NSString *)_currentAddress oldAddress:(NSString *)oldAddress cityState:(NSString *)cityState { if (_currentAddress != nil && _currentAddress.length > 0) { NSLog(@"Your address changed to '%@'. City, State address is: '%@'.", _currentAddress, cityState); } }

Features

  • Feature One

    Here, you can highlight a feature with a few short, but descriptive sentences.
  • Rename This Section

    Of course, you can change the name of this section from “Features” to something else that suits your needs.
  • Feature Three

    If you really need more than a sentence or two to describe your feature, that's okay. You can use as much space as you like, just keep in mind that you don't want to bombard users with text. Keeping things brief will hold their attention.
  • Feature Four

    What makes your product stand out from others like it? Tell visitors here.
  • Delete Bullets

    Don't need so many bullet points? Just delete this text and its header, then hit delete once more to remove the bullet.
  • Add Bullets

    Need more bullets? Just hit enter at the end of bullet text.

 

 

Pricing

14 day 14-day money-back guarantee

FREE

Multiple App

  • Perpetual license

  • 10 applications

  • Can distribute binary products only

  • Commercial use

  • 6 months support

$29.99

Developer

  • Perpetual license

  • Unlimited projects

  • Can distribute code and binary products

  • Commercial use

  • 12 months support