Skip to content

Instantly share code, notes, and snippets.

MengTo / gist:11280811
Created Apr 25, 2014
Gitignore for Xcode/Cocoapods
View gist:11280811
# Created by
### Xcode ###
### Objective-C ###
View gist:7938364
// In Terminal
vim Podfile
// In Podfile
platform :ios, '7.0'
pod 'Canvas'
// Back to Terminal
pod install
MengTo / gist:7887323
Created Dec 10, 2013
The TabBar images are tinted by default. This is a way to use original images.
View gist:7887323
UITabBarController *tabBarView = (UITabBarController *)self.window.rootViewController;
UITabBarItem *item0 = [tabBarView.tabBar.items objectAtIndex:0];
item0.image = [[UIImage imageNamed:@"icon-chat"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
item0.selectedImage = [UIImage imageNamed:@"myImage"];
MengTo / gist:7887303
Created Dec 10, 2013
The Action button on the Navigation bar gets tinted by default. This is a hack to go to its original colours.
View gist:7887303
self.buttonLike.image = [[UIImage imageNamed:@"button-like"] imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal];
MengTo / gist:7887283
Created Dec 10, 2013
Hide the Navigation Bar totally, but it still exists if the Sub screens needs it.
View gist:7887283
// Hide Navigation Bar
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
MengTo / gist:7887257
Last active Dec 30, 2015
Open link in Safari
View gist:7887257
NSString *link = [NSString stringWithFormat:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: link]];
MengTo / gist:7887250
Created Dec 10, 2013
Remove Back button text
View gist:7887250
self.navigationController.navigationBar.topItem.title = @"";
MengTo / gist:7887238
Last active Dec 30, 2015
Send Data from ViewController to ContainerViewController through Segue's Identifier
View gist:7887238
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"dialogScene"]) { = 1;
ViewController *controller = [segue destinationViewController]; =;
// In destinationViewController.h
MengTo / CollectionViewController.m
Created Dec 10, 2013
Sample of a CollectionViewController with 3 sections
View CollectionViewController.m
@property (nonatomic, strong) NSArray *sections;
- (void)viewDidLoad
[super viewDidLoad];
// Cell Sections in Array
self.sections = @[
@{@"identifier": @"firstCell"},
@{@"identifier": @"secondCell"},
@{@"identifier": @"thirdCell"},
MengTo / CollectionViewController.m
Last active Dec 30, 2015
Scrolls to the cell of your CollectionViewController
View CollectionViewController.m
- (void)viewDidAppear:(BOOL)animated {
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:self.indexInt inSection:0]