iOS 7 has given app developers the ability to add directions to their apps thanks to a new class in the Map Kit Framework called MKDirections. In this tutorial we will take a look at this class and create a simple app that lets you search for an address and calculate the distance as well as receive route-based directions from your current location. This tutorial will work on either an iOS device or on the simulator. [Read more…]
iOS 7 Background App Refresh Tutorial
Background App Refresh is a new feature added to iOS 7. What it does is allows apps to quietly wake up and download content all while in the background.
Some of the built in Apple apps such as Mail, Contacts and the Calendar have always done this. When a new email arrives, you open the app and the email is there. Likewise, you add a contact on a remote device and it is automatically added to your contact list on your iPhone. On the other hand, all 3rd party apps could not do this. When notifications of a new email arrive, you open the app and then need to wait for syncronisation to happen. The same happens with apps like Evernote where your new notes are not downloaded until you open the app and sync it.
Background App Refresh changes this. iOS 7 developers can now add a few changes to their code and when done, iOS creates a schedule based on how often you use the app and then at intervals through the day, the app will quietly fetch data from your server so that when the user opens up the app, the syncronisation is already done.
Many apps have already taken advantage of this feature. This includes Dropbox, Evernote, Instapaper, Mailbox, Newsify and OmniFocus to name just a few.
Today, I want to show you how you can get your app to take advantage of this iOS 7 feature. [Read more…]
iBeacons Tutorial for iOS with CLBeaconRegion and CLBeacon
Updated to Swift. Please visit here for the tutorial using Swift.
At WWDC earlier this year (2013) Apple announced iOS 7. Along with that announcement we heard of new API called iBeacons. iBeacons is a technology that uses transmitters and receivers which can let your iOS device know how far you are away from a beacon. One device acts as the transmitter and the other is a receiver.
iBeacon transmitters can either be a dedicated hardware device running Bluetooth 4.0 LE or you can configure a compatible iPhone or iPad to act as a transmitter. The receiving device is a compatible iPhone or iPad that can receive Bluetooth 4.0 LE. Compatible devices include the iPhone 4S and newer and the iPad 3 and newer (including iPad mini).
To give an example of what you could use iBeacons for, think of a group of museums managed by a single company. Each room in each of the museums would have an iBeacon transmitter placed in them. Each beacon is configured with settings or what Apple refers to as an identity. If you are running an app provided by the museum, each time you enter the museum you will be presented with information which changes depending on what room you are in. [Read more…]
NSNotificationCenter Tutorial
NSNotificationCenter is one way you can communicate with other objects in your project. Alternatives include KVO and delegates. Rather than go in to all the details and comparisons of each and when you might opt for a delegate model vs NSNotificationCenter, what I will quickly say is that if you want to simply share a message that a job has completed and perhaps have several other classes listening out then NSNotificationCenter might be the best option for you.
In todays example we are going to create a simple app that lets you search for an address or point of interest on a map. When that search is complete, a pin or several pins will be dropped on the map with the appropriate details for a callout to pop up when a pin is tapped on. [Read more…]
Handy Core Location Functions
To help you cut down on the amount of code you write, Apple provides functions in many of its frameworks. Today, we’ll look at the Core Location Functions that are available in that particular framework.
Just 2 functions are available for this framework although they each can regularly be used in your project. [Read more…]
What is Parse.com?
Parse.com provides a backend service to developers. If your mobile or desktop app requires a backend on the internet, then Parse is one of the options you can choose.
I first came across the service a few months ago and noted that they provide SDKs that let your apps running on various devices connect up to the backend it provides. They provide SDKs for devices running iOS, Android, Windows (Phone) 8, OS X and Javascript.
Today, I want to take a closer look to see what you get, how much it costs and if it potentially replace your own provisioned services and code that you use to interface with your own servers.
A Closer Look at the MKMapViewDelegate Protocol
The MKMapViewDelegate is a protocol that defines how your app can receive updates when changes occur to either the map or any annotations on the map.
As of iOS 6 there are 18 methods available in 7 categories that you can optionally use to receive the updates. Today, I want to cover what each of these methods can do and how you can use them to help bring more functionality to your app.
MKMapView operations often run asynchronously which is why the MKMapViewDelegate comes in handy as actions are processed while you continue using the map and then your app is notified of various changes as available and needed.
This post is not a tutorial as such. Instead, I am just listing the various methods along with details of how they work and what they do. If you want to see some examples of how they are implemented, take a look at the categories listed to the right and select the Map Kit Framework to see tutorials about the various methods.
Responding to Map Position Changes
There are two methods within this category. These are mapVew:regionWillChangeAnimated: and mapView:regionDidChangeAnimated:
The MKUserLocation Class and How to Customise It
The MKUserLocation is a class that is used to create an annotation for the users current location. This particular class is responsible for the blue dot you see on the screenshot to the left. Although I call it a blue dot, it is actually a type of annotation specifically used for the current location of the device.
The MKUserLocation class has 5 properties and no methods. The location, updating and heading property are readonly as you cannot set your location programatically, likewise you cannot update your heading programatically. The way you would set these properties is simply by pointing the phone in another direction or by walking somewhere else. The new values would then be provided to you.
The title and subtitle properties are not readonly. What this means is that you can change the text that is provided when you tap on the blue dot. By default it says “Current Location”. If you set the title and subtitle to some custom text, you can display something different if you wish.
You would do that with the following code:
self.mapView.userLocation.title = @"I'm Here";
self.mapView.userLocation.subtitle = @"Come and Find Me";
The result would be what you see to the right.
The MKUserLocation class is relatively simple. It provides you with where you are, where you are heading and lets you know if the location is being updated. Additionally, we have seen that it also allows you to set the title and subtitle of the annotation as pictured to the right.
This ends this brief tutorial. Next time, we’ll look at how you can customise the look of the MKUserLocation annotation just in case you don’t want to use the standard blue dot.
MKPointAnnotation Tutorial
The MKPointAnnotation is the basic version of an annotation that can be used to display a pin along with a title and subtitle. These can come in handy for displaying basic information on a map. If you want to do more than show a point on a map with a title, then you will need to use MKAnnotation and MKAnnotationView. We’ll look at both of those later in this tutorial. Note that you can change the pin as well and provide a custom image. I’ll show you how in the tutorial below.
The screenshot to the left shows what an MKPointAnnotation looks like in its basic form. This is what this short tutorial will cover today. To get started, download the tutorial from yesterday or create a new Single View Application and drag a map to the view, connect it up as an IBOutlet, import MapKit.framework and the CoreLocation.framework. Include both of these in your header file of the associated class with the view. [Read more…]
MKMapView and MKMapView Delegate Tutorial
The Map Kit Framework is what you use to add a map to your application. There are a number of classes found within the framework that let you provide a rich experience for your users. Today we will look at two of the basic ones. These are MKMapView and MKMapViewDelegate. We will add more tutorials over the coming weeks from the MapKit framework and when iOS 7 launches, we’ll begin adjusting the tutorials accordingly. [Read more…]
- « Previous Page
- 1
- …
- 6
- 7
- 8
- 9
- 10
- …
- 12
- Next Page »