Skip to content

Instantly share code, notes, and snippets.

@keicoder
keicoder / snippet.m
Last active August 29, 2015 13:56
objective-c : presentView and dismissView method with block
//presentView and dismissView method with block
NSLog(@"Presenting view");
[self presentViewController:changeLocationViewController animated:YES completion:^{
NSLog(@"View done presenting");
}];
NSLog(@"Dismissing view");
@keicoder
keicoder / snippet.m
Created February 14, 2014 06:26
objective-c : Add local repo for existing Xcode 5 Project
//Add local repo for existing Xcode 5 Project
//Close Xcode.app
//Open Terminal.app
$ cd /path/to/project/dir
git init
git commit -a -m Initial
//You'll also want to add a .gitignore file to ignore some of the Xcode project files (Google for the exact list).
//When you open the Xcode project next time it will be ready for Source Code use. If you want a "remote" for the repo you'll need to edit .git/config.
@keicoder
keicoder / snippet.m
Created February 14, 2014 01:51
objective-c : styling navigation bar and status bar on the iOS7
//styling navigation bar and status bar on the iOS7
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// style the navigation bar
UIColor* navColor = [UIColor colorWithRed:0.97f green:0.37f blue:0.38f alpha:1.0f];
[[UINavigationBar appearance] setBarTintColor:navColor];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
@keicoder
keicoder / snippet.m
Created February 13, 2014 09:47
objective-c : three steps to create a custom transition in iOS
//three steps to create a custom transition in iOS:
//1. Create the animation controller. The first step is to create a class that implements the UIViewControllerAnimatedTransitioning protocol. This class contains the code to perform the actual animation, so this class is referred to as the animation controller.
//2. Before presenting a view controller, set its transitioning delegate. Before you present a view controller, you should set a class as its transitioning delegate (usually the presenting view controller). By doing this the delegate will get a callback asking for the animation controller to use when presenting the view controller.
//3. Return the animation controller in the callback. Finally, implement the callback method to return an instance of the animation controller you created in step 1.
@keicoder
keicoder / snippet.m
Created February 13, 2014 06:44
objective-c : handle iOS error meggages
//handle iOS error meggages
//Scene is unreachable due to lack of entry points…”?
//just set an identifier. On the attribute inspector on the right pane,
//you'll find a field called "Identifier".
//Put any string in there, and Xcode will be happy again.
@keicoder
keicoder / snippet.m
Created February 13, 2014 06:30
objective-c : make basic table view with custom background and jason data v.7
//make basic table view with custom background and jason data v.7
//add motion effects
- (void)viewDidLoad
{
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
...
// Background image
@keicoder
keicoder / snippet.m
Created February 13, 2014 06:05
objective-c : make basic table view with custom background and jason data v.6
//make basic table view with custom background and jason data v.6
//following Collision Behavior 델리게이트 -> 상단 바운더리를 두어 스냅 시 상단에 뷰가 snap되도록 코딩
//DynamicSandwichViewController.m
@interface DynamicSandwichViewController () <UICollisionBehaviorDelegate> //Collision Behavior 델리게이트
- (UIView*)addRecipeAtOffset:(CGFloat)offset forSandwich:(NSDictionary*)sandwich {
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
@keicoder
keicoder / snippet.m
Created February 13, 2014 05:32
objective-c : make basic table view with custom background and jason data v.5
//make basic table view with custom background and jason data v.5
//Docking views
//DynamicSandwichViewController.m
@implementation DynamicSandwichViewController
{
//Docking views
UISnapBehavior* _snap;
BOOL _viewDocked;
@keicoder
keicoder / snippet.m
Created February 13, 2014 04:42
objective-c : make basic table view with custom background and jason data v.4
//make basic table view with custom background and jason data v.4
//Adding some menu dynamics and takes gesture velocity, add velocity to behavior
//DynamicSandwichViewController.m
@implementation DynamicSandwichViewController
{
NSMutableArray* _views; //use this variable to keep track of the added views
//Adding some menu dynamics
@keicoder
keicoder / snippet.m
Created February 12, 2014 03:30
objective-c : make basic table view with custom background and jason data v.3
//make basic table view with custom background and jason data v.3
//iterate over the recipes and use the addRecipeAtOffset: forSandwich: method
//to add each recipe to the view
//DynamicSandwichViewController.h
@interface DynamicSandwichViewController : UIViewController
@end