Overlay Controller in iOS with Swift 5 – PART II

Overlay Controller in iOS with Swift 5 – PART II
July 3, 2020 No Comments Development,iOS Development Pushpendra Kumar

Hey, Guys welcome to this tutorial. In this complete video, I will make you understand about the quick trick that how you can Overlay Controller. And how you can transfer data in between controllers. And this is a simple way to achieve our goals. By this small trick, you can make your iOS application more attractive and more function-able with the help of Overlay ViewController functionality. So watch the complete video. And if you watched the complete video then do not forget to give your suggestion. Because your feedback & suggestions does matter for me πŸ˜ŠπŸ˜ŠπŸ˜ŠπŸ˜ŠπŸ‘‡πŸ»

And finally, I would like to say that, If you like this video and it’s helpful for your project then click on like button and do not forget to subscribe to this YouTube channel for future updates. 

Great 😊😊😊😊
Now get the useful code of the above video.

Overlay Controller in iOS

Set the following permissions in your info.plist

//MARK:- Set these permission in your info.plist

	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string>Allow for better Result</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>Allow for better Result</string>
	<key>NSLocationUsageDescription</key>
	<string>Allow for better Result</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>Allow for better Result</string>

After that, assign your location manager as mention below!

CLLocationManager in View Controller

        self.locationManager = CLLocationManager()
        self.locationManager.requestAlwaysAuthorization()
        self.locationManager.delegate = self
        self.locationManager.startUpdatingLocation()

Great work 😊😊

Now Add the code for location manager

extension MapController : CLLocationManagerDelegate {
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        print(manager.location?.coordinate ?? "Nothing Found"
    }
}

After that, get the code address.

extension CLLocation {
    func address(cordinate : CLLocationCoordinate2D, complition : @escaping (_ add : String?) -> ()) {
        let location = CLLocation(latitude: cordinate.latitude, longitude: cordinate.longitude)
        
        CLGeocoder().reverseGeocodeLocation(location) { (places, error) in
            if let place = places?.first {
                
                var addressString : String = ""
                if place.subLocality != nil {
                    addressString = addressString + place.subLocality! + ", "
                }
                if place.thoroughfare != nil {
                    addressString = addressString + place.thoroughfare! + ", "
                }
                if place.locality != nil {
                    addressString = addressString + place.locality! + ", "
                }
                if place.country != nil {
                    addressString = addressString + place.country! + ", "
                }
                if place.postalCode != nil {
                    addressString = addressString + place.postalCode! + " "
                }
                
                complition(addressString)
            }
        }
    }
}

Great JOB!!! 

Now make the call for the address from the details controller as mention into above video.

    func cordinate(codinates : CLLocationCoordinate2D) {
        CLLocation().address(cordinate: codinates) { (address) in
            print(address ?? "NOTA FOUND")
            self.locationDes.text = address
        }
    }

Now you have done with it!

In Conclusion, You have done with this tutorial. And hope now the concept of Overlay View Controller in iOS with Swift 5 is clear. If you have any doubts regarding the Overlay ViewController in iOS with Swift 5 then you can comment into the comment box. And if you like this tutorial with a complete description of the simple and attractive tutorial in iOS then pleaseΒ like my videoΒ on YouTube and do not forget to subscribe to myΒ YouTube channel. Because you will get lots of videos related to swift development with very sort tricks.

Besides, If you are more curious about the development and knowing about tutorials then follow the below links πŸ‘‡πŸ»πŸ‘‡πŸ»πŸ‘‡πŸ»πŸ˜Ž

Tags
About The Author
Pushpendra Kumar I am passionate about mobile application development and professional developer at Colour Moon Technologies Pvt Ltd (www.thecolourmoon.com). This website I have made so that I can meet with new challenges and can share here.

Leave a reply

Your email address will not be published. Required fields are marked *