Skip to content

Instantly share code, notes, and snippets.

@bauloc
bauloc / UITableView.swift
Created August 2, 2016 09:47
UITableView
override func viewDidLoad() {
super.viewDidLoad()
let nibName = UINib(nibName: "BLActionCell", bundle:nil)
self.tableAction.registerNib(nibName, forCellReuseIdentifier: "blaction.cell")
//self.modalPresentationStyle = .OverFullScreen
// Do any additional setup after loading the view.
}
Detecting AVPlayer video start stop events
Here is nice simple avplayer piece of code playing a small collection of videos in a queue. My question. I actually want to pause between videos on my queue. Is it possible?
I did note that rate fires twice; status fires just once as does notification.
import UIKit
import AVKit
import AVFoundation
class ViewController: UIViewController {
@bauloc
bauloc / Alert View with Textfield.swift
Created June 2, 2016 04:13
Alert View with Textfield.swift
//1. Create the alert controller.
var alert = UIAlertController(title: "Report", message: "Nhập nội dung", preferredStyle: .Alert)
//2. Add the text field. You can configure it however you need.
alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in
textField.text = ""
// textField.placeholder = "Nhập nội dung..."
})
//3. Grab the value from the text field, and print it when the user clicks OK.
@bauloc
bauloc / test.m
Created April 6, 2016 10:37
tesst
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] init];
AFHTTPRequestOperation *op = [manager GET:requestURLString parameters:parameter success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
DDLog(@"%@", dic);
block(dic);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", [error description]);
@bauloc
bauloc / UICollectionView.m
Created April 4, 2016 03:55
UICollectionview Delegate & Datasource
#pragma mark - UICollectionView
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 10;
}
@bauloc
bauloc / get flatform device.m
Created March 5, 2016 05:06
Get Flatform Device
// Lấy thông tin thiết bị
+ (NSString *) platformType
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
// NSLog(@"iPhone Device%@",[self platformType:platform]);
@bauloc
bauloc / Resize Image.m
Created March 5, 2016 05:05
Resize Image
// Resize Image
+ (UIImage *)ResizeImage:(UIImage*)originalImage scaledToSize:(CGSize)size
{
//avoid redundant drawing
if (CGSizeEqualToSize(originalImage.size, size))
{
return originalImage;
}
//create drawing context
@bauloc
bauloc / performBlock after delay.m
Last active March 5, 2016 05:03
performBlock after delay
+ (void) performBlock:(void(^)())block afterDelay:(NSTimeInterval)delay {
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), block);
}
@bauloc
bauloc / Transport Security has Blocked a cleartext HTTP.xml
Last active March 5, 2016 05:04
Transport Security has Blocked a cleartext HTTP
For example you can add a specific domain like:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>