Skip to content

Instantly share code, notes, and snippets.

View zafar007's full-sized avatar

Zafar zafar007

View GitHub Profile
@zafar007
zafar007 / exampleTableView.m
Created September 15, 2019 14:31 — forked from mteece/exampleTableView.m
Fix for heightForHeaderInSection as it is called before viewForHeaderInSection and the view size until I create it.
- (CGSize)tableView:(UITableView *)tableView sizeForHeaderLabelInSection:(NSInteger)section
{
NSString *text = [self tableView:tableView titleForHeaderInSection:section];
CGSize constraint = CGSizeMake(self.view.frame.size.width - kSectionTitleLeftMargin - kSectionTitleRightMargin, kMaxSectionTitleHeight);
return [text sizeWithFont:[self fontForSectionHeader] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
// Playground - noun: a place where people can play
import UIKit
enum SubtitleType {
case SubRip, SubStationAlpha, LRC, SAMI, YouTube, SubViewer, MicroDVD, WebVTT, TTML, Unknown
func description() -> String {
switch self {
case .SubRip:
@zafar007
zafar007 / Cookie
Created December 20, 2016 05:51 — forked from anonymous/Cookie
@zafar007
zafar007 / ViewController.swift
Created October 1, 2016 15:26 — forked from kellyegan/ViewController.swift
Send emails with attachments in iOS using Swift
//
// ViewController.swift
// SendEmailWithAttachment
//
// Created by Kelly Egan on 3/17/15.
// Copyright (c) 2015 Kelly Egan. All rights reserved.
//
import UIKit
import MessageUI
@zafar007
zafar007 / gist:2e64da9b5a69094b1971b9edc9ce00d6
Created September 9, 2016 19:25 — forked from igaiga/gist:1308730
Set UIWebView's user agent into NSMutableURLRequest
NSString *urlString = [NSString stringWithFormat:@"http://example.com/foo"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
// get User Agent in UIWebView
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSLog(@"UserAgent: %@", userAgent);
[webView release];
[request setValue:userAgent forHTTPHeaderField:@"User-Agent"];
NSURLResponse *response;