Last active
November 7, 2017 15:56
-
-
Save rodydavis/5373bd1311ee4271c51293eb8cd7e644 to your computer and use it in GitHub Desktop.
Table View Cell button actions and actions from image view
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! | |
@IBOutlet weak var lblDetail2: UILabel! | |
@IBOutlet weak var lblUtility1: UILabel! | |
@IBOutlet weak var lblUtility2: UILabel! | |
@IBOutlet weak var imgCallButton: UIImageView! | |
@IBOutlet weak var imgEmailButton: UIImageView! | |
@IBOutlet weak var imgContactDetails: UIButton! | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
// Initialization code | |
imgCallButton.isUserInteractionEnabled = true | |
imgCallButton.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(dialPhone(_:)))) | |
imgEmailButton.isUserInteractionEnabled = true | |
imgEmailButton.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(sendEmail(_:)))) | |
imgContactDetails.addTarget(self, action:#selector(handleRegister(sender:)), for: .touchUpInside) | |
} | |
override func setSelected(_ selected: Bool, animated: Bool) { | |
super.setSelected(selected, animated: animated) | |
// Configure the view for the selected state | |
} | |
@objc func dialPhone(_ sender: UITapGestureRecognizer){ | |
let number = data[imgCallButton.tag].phone ?? "" | |
print("Number: " + number) | |
UIApplication.makeAPhoneCall(number: number.replacingOccurrences(of: "-", with: "")) | |
} | |
@objc func sendEmail(_ sender: UITapGestureRecognizer){ | |
let email = data[imgEmailButton.tag].email ?? "" | |
print("Email: " + email) | |
UIApplication.sendEmail(to: email, body: "") | |
print("Email Sent") | |
} | |
@objc func handleRegister(sender: UIButton){ | |
let buttonRow = sender.tag | |
contactID = data[buttonRow].ID! | |
print("Button Func Row: \(buttonRow), Contact ID: \(contactID)") | |
// print(IDs) | |
print(" Data: \(data.count)") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment