Skip to content

Latest commit

 

History

History
227 lines (175 loc) · 6.65 KB

File metadata and controls

227 lines (175 loc) · 6.65 KB

How to perform sequential request with Alamofire and update a progressHUD at every step in Swift 3


How can I force landscape mode in one viewController

__my resolution is here


When landscape, textField's inputAccessoryView doesn't shown


Animating autoLayout doesn't work


When can I activate/deactivate layout constraints?

TL;DR: Delete weak statement from IB Outlet decleration.

How to angle a uilabel in ios [duplicate]


UITableViewCell animation

// TL;DR: Use 
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
    // animation logic
}
// from UITableViewDelegate

How can i fit GMSCircle to map?

import GoogleMaps

extension GMSCircle {
    func bounds () -> GMSCoordinateBounds {
        func locationMinMax(positive : Bool) -> CLLocationCoordinate2D {
            let sign:Double = positive ? 1 : -1
            let dx = sign * self.radius  / 6378000 * (180/M_PI)
            let lat = position.latitude + dx
            let lon = position.longitude + dx / cos(position.latitude * M_PI/180)   
            return CLLocationCoordinate2D(latitude: lat, longitude: lon)
        }

        return GMSCoordinateBounds(coordinate: locationMinMax(true),
            coordinate: locationMinMax(false))
    }
}

// usage
let update = GMSCameraUpdate.fitBounds(myCircle.bounds())
myMap.animateWithCameraUpdate(update)

WKWebView is not loading url

TL;DR: you just need to take permission of TransportSecurit to YES in info.plist file

How can i change marker icon while clustering, Google Maps, iOS

TL;DR: You should add your code to below function, for adding custom marker icon
- (GMSMarker *)markerWithPosition:(CLLocationCoordinate2D)position
                             from:(CLLocationCoordinate2D)from
                         userData:(id)userData
                      clusterIcon:(UIImage *)clusterIcon
                         animated:(BOOL)animated

Move a view up only when the keyboard covers an input field

__Gist for my solution is here.


How to set cornerRadius for only top-left and top-right corner of a UIView?

extension UIView {
   func roundCorners(corners: UIRectCorner, radius: CGFloat) {
        let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
        let mask = CAShapeLayer()
        mask.path = path.cgPath
        layer.mask = mask
    }
}

TextField's value change handling

// case: textfields' isEnabled property depend on each other's value

// Setup Func
private func setupTextfields() {
    tfSerialNumber.tag = 1
    tfSerialNumber.addTarget(self, action: #selector(textFieldValueChanged(textField:)), for: .editingChanged)

    tfRequestNumber.tag = 2
    tfRequestNumber.addTarget(self, action: #selector(textFieldValueChanged(textField:)), for: .editingChanged)
}

// Target Func
@objc private func textFieldValueChanged(textField: UITextField) {
    if let t = tfSerialNumber.text {
        if !t.isEmpty {
            tfRequestNumber.text = ""
            tfRequestNumber.isEnabled = false
        } else {
            tfRequestNumber.isEnabled = true
        }
    }
    if let t = tfRequestNumber.text {
        if !t.isEmpty {
            tfSerialNumber.text = ""
            tfSerialNumber.isEnabled = false
        } else {
            tfSerialNumber.isEnabled = true
        }
    }
}

Moya : Parameter Encoding for POST method not working. #1116

public var parameterEncoding: ParameterEncoding {
    switch self {
    case .postMethodButParametersShouldSendOverURL:
        return URLEncoding(destination: .queryString)
    default:
        return URLEncoding.default
    }
}

E-Mail validation regex

extension String {
    func isValidEMail() -> Bool {
        let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
        return NSPredicate(format: "SELF MATCHES %@", emailRegex).evaluate(with: self)
    }
}

How can my iphone app detect its own version number?

if let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String {
    yourCoolLabel.text = "v\(appVersion)"
}

Can you animate a height change on a UITableViewCell when selected?

extension CreatePlayStep2VC: UITableViewDelegate {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.beginUpdates()
        tableView.endUpdates()
    }
    
    func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
        tableView.beginUpdates()
        tableView.endUpdates()
    }
}

Changing a cell's value affect other cells

override func prepareForReuse() {
    super.prepareForReuse()
    
    // clear attributes which will re-assign
}

Convert dictionary to Json string in Swift 3

do {
    let jsonData = try JSONSerialization.data(withJSONObject: DICT, options: .prettyPrinted)
    // here "jsonData" is the dictionary encoded in JSON data

    let decoded = try JSONSerialization.jsonObject(with: jsonData, options: [])
    // here "decoded" is of type `Any`, decoded from JSON data
    print(String(data: jsonData, encoding: .utf8))
} catch {
    print(error.localizedDescription)
}

Cool camera pod


Cool drawer menu pod