A UIKit based geotagging app that let's you save places you have visited with images.

Related tags

Guides MyLocations
Overview

My Locations

Getting Started Using Core Location

  • A CLLocationManager() performs the location updating
  • It sends its updates to its delegate, so make sure to set it up before doing anything else
  • Get permission using the manager first. "while in use" is enough.
  • If user ever denies it, make sure we handle the permission status to get permission before anything else. This can be an alert if authorizationStatus is .denied or .restricted
  • Set locationManager's desired accuracy. Options start with kCLLocation###.
  • Call locationManager.startUpdatingLocation() to get location info and send it to the delegate.
  • In the delegate, use the location as you see fit (update UI)

Error Handling

GPS services is prone to errors. Use an instance variable to store any errors received from delegate. Then, make sure the following are taken care of:

  1. Location services restricted from error code
  2. Location services restricted from CLLocationManager
  3. Currently updating location, waiting for more accurate results
  4. First time using the app. Tap 'Get My Location' to Start".

Reverse Geocoding (CLGeocoder)

Setup instance variables to store current state, errors, and results.

  • use geoCoder.reverseGeocodeLocation to decode and handle results and errors.
  • update UI based on error code and results.

Improving results

  • If accuracy is not within desired accuracy, see if the locations move within 10 meters in 10 seconds. If so, update address and done.

  • Add a timeout timer if we are waiting too long for a result.

Short Summary

  • A lot of work is done to make sure that the UI is updated appropriately depending on the state of location update and reverse geocoding. To account for different errors and the delays for accurate results, we need instance variables to keep track of these changes.
  • The updateLabels() function is called whenever we need to update the UI and it looks at the state of the instance variables to decide what to display

Misc

  • Unwind segues will not trigger viewDidLoad()

Creating Custom UIViews (HUD)

  • subclass from UIView, which has a (frame: ) initializer to setup an empty view with the same size as frame (which can be obtained using .bounds on any other view).
  • Therefore, to create a hud view, we will need a parent view to sit in. It's convenience initializer will need a (inView view: UIView).
  • Once parent view is obtained, create a new hud view with the bounds of the parent, then disable interaction of parent, add subview to parent using .addSubView(_ view: UIView)
  • Set what the view should look like and return the view.
When using the view
  • The parent view should be the oldest parent... to cover the whole screen.
  • Use .view on a view controller to obtain its view.
Designing custom shape for custom view
  • override draw(_ rect: CGRect) function

Draw a rectangle:

  • CGRect(x, y, width, height)

Draw a rounded rectange:

  • UIBezierPath(roundedRect, corderRadius)

Fill Color

  • UIColer(coler, alpha).setFill()
    • This prepares the color for the subsequent .fill() operation
  • {shape}.fill()

Draw an image:

  • declare the top left point where the image should be drawn.
    • use CGPoint(x, y)
  • Use image.draw(at: CGPoint) to draw the image

Draw a text:

  • Make an NSAttributedString.Key array to instruct what the text should look like. e.g.

     let attribs = [ 
         NSAttributedString.Key.font: UIFont.systemFont(ofSize: 16),
         NSAttributedString.Key.foregroundColor: UIColor.white
     ]
    
  • get the size of the text:

     let textSize = text.size(withAttributes: attribs)
    
  • same as image, get the top left CGPoint where the text should be drawn.

  • Then call text.draw(at: CGPoint, withAttributes: [NSAttributedString.Key])


UIView Animation

  • Set initial look and a transform, e.g.

     alpha = 0
     transform = CGAffineTransfrom(...)
    
  • Then call UIView.animate(...) { end look of self view }

Remove hud from parent

  • call removeFromSuperView()
You might also like...
You can touch My Swift, MapKit, UX skills! :D
You can touch My Swift, MapKit, UX skills! :D

What is it? 🙋🏻 It's a pet project which has been developed as a code challenge. It's written purely in Swift without using 3rd party frameworks. Wha

his is my second app, made right after the I am Rich app
his is my second app, made right after the I am Rich app

I-am-Poop 💩 Hello everyone! This is my second app, made right after the I am Rich app, to better fixate the concepts I learned during this lesson, wh

Demonstration of how to integrate AppleScript/Cocoa scripting into a Catalyst app
Demonstration of how to integrate AppleScript/Cocoa scripting into a Catalyst app

CatalystAppleScript Trivial demonstration showing how to build support for AppleScript into a Catalyst app. Showcases multiple commands and variables

A package to help track how often the user opened the app and if they opened it in the current version before.

AppOpenTracker AppOpenTracker provides an observable AppOpenTracker.shared instance that can be used to track the last version that the app was opened

This little app aims to help teach me how to implement more then one API in one single application in a reusable and properly structured manner.

LilAPI App News & Weather This little API app combines two of Jordan Singers Lil Software API's into one app. The goal with this app was to learn how

SpaceX rocket listing app using RxSwift and CLEAN Architecture with MVVM
SpaceX rocket listing app using RxSwift and CLEAN Architecture with MVVM

Jibble SpaceX rocket listing app using RxSwift and CLEAN Architecture with MVVM Demo Features Reactive Bindings URL / JSON Parameter Encoding Filter Y

A trivial app for storing and viewing famous quotes

Paraphrase A trivial app for storing and viewing famous quotes This app was specifically designed to accompany a tutorial series about modern app infr

SwiftUI module library for adding seasons theme animations to your app
SwiftUI module library for adding seasons theme animations to your app

HolidayThemes SwiftUI module library for adding seasons theme animations to your app. Requirements iOS 13.0+ Xcode 12.0+ Installation Swift Package Ma

Movies app written in Swift 5 using the Custom API created on the Mocky website
Movies app written in Swift 5 using the Custom API created on the Mocky website

Movie App shows you collections of TV streaming and other movies. Movie app writ

Owner
Xiao Quan 全笑
Xiao Quan 全笑
iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit

iOS (Swift 5): MVVM test with Combine and UIKit MVVM and functional reactive programming (FRP) are very used in iOS development inside companies. Here

Koussaïla BEN MAMAR 2 Dec 31, 2021
Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets.

SwiftUI-LazyVGrid Exemplify a LazyVGrid in SwiftUI in a MVVM pattern with Mock Data and images in assets. Screenshots Samples IP & Credits All those b

Ethan Halprin 3 Aug 9, 2022
Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.

iOS (Swift 5): Test MVVM avec Combine et UIKit L'architecture MVVM et la programmation réactive fonctionnelle sont très utlisées dans le développement

Koussaïla BEN MAMAR 2 Nov 5, 2022
A treelist ViewController that implemented with Uikit (swift).

TreeList ViewController A treelist viewcontroller that implemented with Uikit (swift). Features The sections could be expanded and folded by clicking

Vincent Liu 2 Dec 12, 2021
Cryptocurrency price checker, build with UIKit and MVC + Delegate pattern.

Coin Check Cryptocurrency price checker. The app fetch from CoinAPI.io the latest coin prices, build with UIKit and MVC + Delegate pattern. Features S

Anibal Ventura 0 Jan 10, 2022
Swift, UIkit, Anchorage, Clean Architecture, UICollectionViewDiffableDataSourcem, MVVM+Coordinators patterns

About the app iOS project realized with Swift, UIkit, Anchorage, Clean Architecture, UICollectionViewDiffableDataSource and MVVM + Coordinators patter

Luca Berardinelli 4 Dec 29, 2022
SwiftLint - A tool to enforce Swift style and conventions, loosely based on Swift Style Guide.

SwiftLint - A tool to enforce Swift style and conventions, loosely based on Swift Style Guide.

Realm 16.9k Dec 30, 2022
A simple menubar app can give you quick access to some macOS functions

OneClick This simple menubar app can give you quick access to some macOS functio

mik3 32 Dec 19, 2022
This is an iOS Safari Extension Sample that adds a "Develop menu" to Safari on iOS to allow you to analyze websites.

Develop Menu for Mobile Safari This is an iOS Safari Extension that adds a "Develop menu" to Safari on iOS to allow you to analyze websites. This is a

Watanabe Toshinori 1 Dec 7, 2022
A blog project where you can write your articles, upload photos, categorize them, and add them to your favorites

A blog project where you can write your articles, upload photos, categorize them, and add them to your favorites. The aim of the project is to learn the use of Core Data.

Cem 7 Mar 21, 2022