Skip to content

This extension is used to get top most ViewController in order to show all type of alerts correctly

License

Notifications You must be signed in to change notification settings

hamza-faroooq/Swift-TopViewController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Introduction

Hi, Humans!

My name is Hamza Farooq and I love 'Swift' programming. Do check HFSoftUI also... :-)

Swift-TopViewController

This extension is used to get top most ViewController in order to show all type of alerts correctly

Simple Usage

Do the following simple steps to add this extension in your project and present alerts and action sheets without any inconvenience.

Simply download or copy this code and place it in your project anywhere. I suggest you to make a new file named Extensions.swift and place this code in that file. (Click on the link, this will take you to the directory where extension is placed)

Example

if let topViewController = UIApplication.topViewController() {
    topViewController.present(actionSheet, animated: true, completion: nil)
}
  • Use Optional Binding just in case if the controller is not found to prevent unintended behaviour of this extension.
  • Weather you are using Navigation controller or TabBar controller or simple presented controller, this extension will give the exact controller you want.

I uses this class for my own personal use, if you want to use some other methods or want to modify this class on your own, you can. :-)

Contributions

Your contributions are most welcomed. Do let me know if you find any kind of issue while using this file. Please open an issue to discuss that problem. Thanks

Auther

Hamza Farooq, hamza_faroooq@yahoo.com

License

MIT (Click Me O_o)

About

This extension is used to get top most ViewController in order to show all type of alerts correctly

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages