This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)keyboardWillShow:(NSNotification *)notification { | |
CGRect keyboardFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; | |
CGRect convertedFrame = [self.view convertRect:keyboardFrame fromView:self.view.window]; | |
CGFloat animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; | |
UIViewAnimationCurve animationCurve = [[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue]; | |
[UIView animateWithDuration:animationDuration delay:0 options:animationCurve animations:^{ | |
self.viewToMove.bottom = self.view.height - convertedFrame.size.height - 15; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TPSpringyModalTransition.h | |
// iPeru | |
// | |
// Created by Pietro Rea on 5/4/14. | |
// Copyright (c) 2014 Pietro Rea. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface TPSpringyModalTransition : NSObject <UIViewControllerAnimatedTransitioning> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreData | |
class CoreDataManager { | |
var context:NSManagedObjectContext | |
var psc:NSPersistentStoreCoordinator | |
var model:NSManagedObjectModel | |
var store:NSPersistentStore? | |
init() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var alert = UIAlertController(title: "Title", message: "Alert view message", preferredStyle: UIAlertControllerStyle.Alert) | |
alert.addAction(UIAlertAction(title: "Save", style: .Default, handler: { (action: UIAlertAction!) in | |
println("Saved") | |
})) | |
alert.addAction(UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in | |
println("Cancel") | |
})) | |
presentViewController(alert, animated: true, completion: nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIView *autoLayoutView = [[UIView alloc] init]; | |
autoLayoutView.backgroundColor = [UIColor redColor]; | |
autoLayoutView.translatesAutoresizingMaskIntoConstraints = NO; | |
[self.view addSubview:autoLayoutView]; | |
NSDictionary *views = NSDictionaryOfVariableBindings(autoLayoutView); | |
NSArray *hConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|[autoLayoutView]|" | |
options:nil | |
metrics:nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html | |
- (NSDate *)dateFromRFC3339String:(NSString *)dateString { | |
static NSDateFormatter *sRFC3339DateFormatter = nil; | |
if (sRFC3339DateFormatter == nil) { | |
sRFC3339DateFormatter = [[NSDateFormatter alloc] init]; | |
NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; | |
[sRFC3339DateFormatter setLocale:enUSPOSIXLocale]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In UIViewController subclass | |
@interface UIWindow (AutoLayoutDebug) | |
+ (UIWindow *)keyWindow; | |
- (NSString *)_autolayoutTrace; | |
@end | |
- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation | |
{ | |
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Add to Project-Prefix.pch | |
#ifdef DEBUG | |
#define debugLog(...) NSLog(__VA_ARGS__) | |
#else | |
#define debugLog(...) // Nothing | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *html = @"<bold>Wow!</bold> Now <em>iOS</em> can create <h3>NSAttributedString</h3> from HTMLs!"; | |
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}; | |
NSAttributedString *attrString = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUTF8StringEncoding] options:options documentAttributes:nil error:nil]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dataTask = urlSession.dataTaskWithURL(url!, completionHandler: { [unowned self] (data: NSData!, response: NSURLResponse!, error: NSError!) -> Void in | |
//add code here | |
}) |
OlderNewer