Skip to content

Instantly share code, notes, and snippets.

View imnaveensharma's full-sized avatar

Naveen Sharma imnaveensharma

  • TechAhead Software Pvt. Ltd.
  • Noida, India
View GitHub Profile
import UIKit
import AWSS3
//pod 'AWSS3'
//https://github.com/maximbilan/Swift-Amazon-S3-Uploading-Tutorial
//https://www.swiftdevcenter.com/upload-image-video-audio-and-any-type-of-files-to-aws-s3-bucket-swift/
typealias progressBlock = (_ progress: Double) -> Void
typealias completionBlock = (_ response: Any?, _ error: Error?) -> Void
@imnaveensharma
imnaveensharma / UIKit_ClickableLabel.swift
Last active July 24, 2020 05:09
Enable user interaction on UILabel by UITapGestureRecognizer
private func makeLabelClickable() {
self.label.isUserInteractionEnabled = true
let guestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(labelClicked(_:)))
self.label.addGestureRecognizer(guestureRecognizer)
}
@objc func labelClicked(_ sender: Any) {
}
@imnaveensharma
imnaveensharma / UIKit_ScrollableTableHeaderView.swift
Created July 24, 2020 04:31
Scroll the header view along with the UITableView
extension ViewController: UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard let tableView = scrollView as? UITableView,
let visible = tableView.indexPathsForVisibleRows,
let first = visible.first else {
return
}
let headerHeight = tableView.rectForHeader(inSection: first.section).size.height
class func emptyTableCell() -> UITableViewCell {
let cellDefault: UITableViewCell = UITableViewCell(style: .default, reuseIdentifier: "Cell")
cellDefault.selectionStyle = .none
cellDefault.textLabel?.text = ""
cellDefault.imageView?.image = nil
return cellDefault
}
@imnaveensharma
imnaveensharma / UIKit_AddTarget.swift
Last active July 25, 2020 04:51
Add target through selector
self.btn.addTarget(self, action: #selector(tapBtn(sender:)), for: .touchUpInside)
// MARK: - Selectors Actions ::
@IBAction func tapBtn(sender: UIButton) {
}
@imnaveensharma
imnaveensharma / UIWebView_References_Finder.rtf
Last active July 16, 2020 11:17
Find UIWebView references in iOS App
To detect use of UIWebView in project.
1. Open Terminal
2. CD <Path to your App>
3. Press return
4. grep -r UIWebView .
To detect use of UIWebView in binary frameworks.
@imnaveensharma
imnaveensharma / DebugLog.swift
Created July 13, 2020 14:47
Constant file with custom methods to print logs with extra informations for development/debug phase only.
#if DEBUG
func dLog(message: String, filename: String = #file, function: String = #function, line: Int = #line) {
print("[\((filename as NSString).lastPathComponent):\(line)] \(function) - \(String(describing: message))")
}
func classStart(filename: String = #file, function: String = #function, line: Int = #line) {
print("ClassStart", "[\((filename as NSString).lastPathComponent):\(line)] \(function)")
}
func classEnd(filename: String = #file, function: String = #function, line: Int = #line) {