This file contains 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
//Updated for Swift 4 | |
//One Button | |
class ViewController: UIViewController { | |
@IBAction func showAlertButtonTapped(_ sender: UIButton) { | |
// create the alert | |
let alert = UIAlertController(title: "My Title", message: "This is my message.", preferredStyle: UIAlertControllerStyle.alert) |
This file contains 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
//Extension to make it easy for UIColor init | |
extension UIColor { | |
convenience init(red: Int, green: Int, blue: Int) { | |
let newRed = CGFloat(red)/255 | |
let newGreen = CGFloat(green)/255 | |
let newBlue = CGFloat(blue)/255 | |
self.init(red: newRed, green: newGreen, blue: newBlue, alpha: 1.0) | |
} | |
} |
This file contains 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
override func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? { | |
let indexPathIndex = tableView.indexPathForSelectedRow | |
let indexPath = indexPathIndex?.row ?? 0 | |
let callButton = UITableViewRowAction(style: .normal, title: "📞\n Call") { action, index in | |
print("call button tapped") | |
let number = data[indexPath].phone ?? "" | |
print("Number: " + number) | |
UIApplication.makeAPhoneCall(number: number.replacingOccurrences(of: "-", with: "")) |
This file contains 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 DashboardCell: UITableViewCell { | |
// MARK: - Properties | |
static let reuseIdentifier = "DashboardCell" | |
// MARK: - | |
@IBOutlet weak var lblHeaderTitle: UILabel! | |
//@IBOutlet weak var imgContactDetails: UIImageView! | |
@IBOutlet weak var lblDetail1: UILabel! |
This file contains 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
func map(address: String, title: String, name: String) { | |
let location = address | |
let geocoder = CLGeocoder() | |
geocoder.geocodeAddressString(location) { [weak self] placemarks, error in | |
if let placemark = placemarks?.first, let location = placemark.location { | |
let mark = MKPlacemark(placemark: placemark) | |
let coordinates:CLLocationCoordinate2D = placemark.location!.coordinate | |
if var region = self?.mapView.region { | |
region.center = location.coordinate |
This file contains 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
// | |
// ContactMapView.swift | |
import UIKit | |
import MapKit | |
import Contacts | |
import CoreLocation | |
var addressString = "" //Pass Address String from other View Controllers |
This file contains 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
import UIKit | |
import MapKit | |
class MapViewController: UIViewController, MKMapViewDelegate { | |
@IBOutlet var mapView: MKMapView! | |
var restaurant: RestaurantMO! | |
override func viewDidLoad() { |
This file contains 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
/* | |
https://github.com/hackiftekhar/IQKeyboardManager | |
Extremely easy to install Swift or Objective-C. | |
Here how it works: | |
IQKeyboardManager (Swift):- IQKeyboardManagerSwift is available through CocoaPods, to install it simply add the following line to your Podfile: (#236) | |
*/ | |
// pod 'IQKeyboardManagerSwift' | |
//In AppDelegate.swift, just import IQKeyboardManagerSwift framework and enable IQKeyboardManager. |
This file contains 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
//States | |
let states = [ "AK","AL","AR","AS","AZ","CA","CO","CT","DC","DE","FL","GA","GU","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","PR","RI","SC","SD","TN","TX","UT","VA","VI","VT","WA","WI","WV","WY"] |
This file contains 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
import ContactsUI | |
import UIKit | |
class ViewController: UIViewController, CNContactPickerDelegate { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
openAddressbook(vc: ViewController()) | |
} | |
OlderNewer