Skip to content

Instantly share code, notes, and snippets.

View pawankmrai's full-sized avatar
💭
I may be slow to respond.

Pawan Kumar Rai pawankmrai

💭
I may be slow to respond.
View GitHub Profile
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>PayPal</title>
<style type='text/css'>
html,body {margin: 0;padding: 0;width: 100%;height: 100%;}html {display: table;}body {display: table-cell;vertical-align: middle;text-align: center;}
</style>
</head>
//
// AppImageView.swift
// Socho
//
// Created by Pawan on 06/06/18.
// Copyright © 2018 Pawan. All rights reserved.
//
import Foundation
import UIKit
@pawankmrai
pawankmrai / CustomTableViewCell
Created December 5, 2017 07:23
Find table view from inside cell in swift 3
extension UIView {
func parentView<T: UIView>(of type: T.Type) -> T? {
guard let view = self.superview else {
return nil
}
return (view as? T) ?? view.parentView(of: T.self)
}
}
extension UITableViewCell {
@pawankmrai
pawankmrai / gist:ff502861fce79e5a35a2b02d2aff3af7
Created June 9, 2017 07:37
Mardinate-China Map Coordinate Fix
const double x_pi = 3.14159265358979324 * 3000.0 / 180.0;
-(CLLocationCoordinate2D)bd_encryptWithCoordinate:(CLLocationCoordinate2D)coordinate{
double x = coordinate.longitude;
double y = coordinate.latitude;
double z = sqrt (x * x + y * y) + 0.00002 * sin (y * x_pi);
double theta = atan2 (y, x) + 0.000003 * cos (x * x_pi);
UILabels and Auto Layout have a problem, because there aren't enough conditions to solve the layout uniquely.
The number of lines in a label is affected by its width, which in turn is affected by the number of lines etc...
To get a label to play nicely, you need to ensure it has a defined width,
it has its number of lines set to 0 and you might need to create a subclass that includes the following:
class MultilineLabelThatWorks : UILabel {
override func layoutSubviews() {
super.layoutSubviews()

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep -H UI_APPEARANCE_SELECTOR ./* | sed 's/ __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0) UI_APPEARANCE_SELECTOR;//'

UIActivityIndicatorView

#include <dispatch/dispatch.h>
typedef void (^MHChannelsBlock)(id sender, NSDictionary *dictionary);
/*!
* A "channel" is like a private NSNotificationCenter between just two objects
* (although more are possible).
*
* Instead of making your objects, such as two view controllers, communicate