This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LaunchViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
} | |
override func viewDidAppear(_ animated: Bool) { | |
Thread.sleep(forTimeInterval: 0.5) // Pause for half a second | |
instantiateHomeViewContoller() // Instantiate HomeViewController |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See: https://stackoverflow.com/questions/26943808/ios-how-to-run-a-function-after-device-has-rotated-swift | |
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { | |
super.viewWillTransition(to: size, with: coordinator) | |
if UIDevice.current.orientation.isLandscape { | |
print("Landscape") | |
} else { | |
print("Portrait") | |
} | |
//Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See: https://freakycoder.com/ios-notes-31-how-to-hide-keyboard-by-touching-anywhere-cdf4f0c5151c | |
01. Create an extension | |
import UIKit | |
extension UIViewController { | |
func hideKeyboardWhenTappedAround() { | |
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(UIViewController.dismissKeyboard)) | |
tap.cancelsTouchesInView = false | |
view.addGestureRecognizer(tap) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See:https://makeapppie.com/2016/07/11/programmatic-navigation-view-controllers-in-swift-3-0/ | |
Go to ViewController class and add the following method: | |
@IBAction func fourFiveToggleButton(_ sender: UIButton){ | |
performSegue(withIdentifier: "mySegueIdentifier", sender: self) | |
} | |
To unwind see: https://www.andrewcbancroft.com/2015/12/18/working-with-unwind-segues-programmatically-in-swift/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In plist add | |
Application does not run in background - > YES | |
Now your app will reopen each time from the rootViewController, not where it left off. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See: https://chariotsolutions.com/blog/post/importing-data-via-custom-file-types-in/ | |
01. Define the File Type | |
First we need to define a file type extension that our application will support. This is also known as a Uniform Type Identifier (UTI). For our purpose, we will use a filetype of 'csm' (for Chariot Solutions Mobile). The contents of this file will be some string. It could really be almost anything, but for simplicity we will use a string. | |
For a list of Apple defined UTIs, look here: http://developer.apple.com/library/ios/#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259-SW1. | |
Once we know what our custom file type extension is, we can add support for it to the project by modifying the Info.plist file for the project. We are going to be the owner/exporter of the new file type, so we add the "Exported Type UTIs" key to the Info.plist file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See:https://github.com/maximbilan/ios_airdrop_custom_data | |
var excludedActivities: [Any] = [.postToTwitter, .postToFacebook, .postToWeibo, .message, .mail, .print, .copyToPasteboard, .assignToContact, .saveToCameraRoll, .addToReadingList, .postToFlickr, .postToVimeo, .postToTencentWeibo] as? [Any] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See:https://stackoverflow.com/questions/39309338/how-to-send-and-receive-custom-data-with-airdrop | |
See:https://developer.apple.com/library/content/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html | |
See:https://stackoverflow.com/questions/45154373/creating-custom-uti-for-use-with-airdrop-ios | |
See:https://stackoverflow.com/questions/43195134/how-do-i-import-and-read-a-file-in-my-ios-app | |
01. How to send and receive custom data with AirDrop | |
In my app I have an array of custom data that I want to send to another user with the same app, via AirDrop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
See:https://stackoverflow.com/questions/43823430/using-struct-to-pass-a-variable-swift | |
The right way to pass data would be to: | |
eliminate static variables; | |
give your struct a name that starts with uppercase letter; | |
create instance of your struct; and | |
pass this instance to the destination view controller in prepare(for:sender:). | |
01. In the first VC: |