Skip to content

Instantly share code, notes, and snippets.

View mjjimenez's full-sized avatar

Mark Jimenez mjjimenez

View GitHub Profile
@markSci5
markSci5 / hide-tab-bar
Created August 19, 2013 04:27
Hide the tab bar when pushing a new controller.
// Create the UIViewController
MyViewController * viewController = [[MyViewController alloc] init];
// Hide the tab bar
viewController.hidesBottomBarWhenPushed = YES;
// Push onto the view stack
[[self navigationController] pushViewController:viewController animated:YES];
@markSci5
markSci5 / Instructions
Created August 13, 2013 02:56
Convert iPhone storyboard to iPad.
1. Duplicate your iPhone-Storyboard and rename it MainStoryboard_iPad.storyboard
2. Open this file any text editor.
3. Search for targetRuntime="iOS.CocoaTouch"and change it to targetRuntime="iOS.CocoaTouch.iPad"
4. Now save everything and reopen Xcode -> the iPad-Storyboard contains the same as the iPhone-file but everyting could be disarranged
@markSci5
markSci5 / git-push-all
Created August 13, 2013 02:09
Push all remote branches and their tags
git push --all
git push --tags
@Marlunes
Marlunes / hide_status_bar
Created July 16, 2013 07:54
FORCE HIDE STATUS BAR FOR IOS 7 AND 6
//viewDidload
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
@Marlunes
Marlunes / Core_data_migration
Created July 9, 2013 09:03
CORE DATA MIGRATION
//in AppDelegate.m
// Add this inside NSPersistenStoreCoordinator delegate
/* Note: NSPersistenStoreCoordinator delegate is automatically created if you create
empty application and selected "use Core Data"
*/
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
@Marlunes
Marlunes / sqlite_addDB
Created July 4, 2013 07:01
ADDING SQLite DATABASE
//all stuffs will be on the Appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//some appdelegate codes here......
[self checkDatabaseIfExists]; //Makes sure that the app has a database
//some appdelegate codes here ......
@Marlunes
Marlunes / alert_message
Created July 4, 2013 06:53
ALERT MESSAGE
/*
To call:
[self showErrorWithTitle:@"Error" withMessage:@"Your Device Sucks!"];
*/
- (void)showErrorWithTitle:(NSString *)title withMessage:(NSString *)message{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:title message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
@Marlunes
Marlunes / customize_picker
Created July 4, 2013 06:30
CUSTOMIZE PICKERVIEW TEXT/CONTENT
// Implement pickerview delegate
// Add some stuffs inside
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel *pickerLabel = (UILabel *)view;
CGRect frame = CGRectMake(0,0,250,40);
pickerLabel = [[UILabel alloc] initWithFrame:frame];
[pickerLabel setTextAlignment:UITextAlignmentCenter];
@Marlunes
Marlunes / resize_image
Created July 4, 2013 06:24
RESIZING IMAGE PROPORTIONALLY
/* To call:
resizedImage = [self imageByScalingProportionallyToSize:myImageView.size usingImage:myImage];
*/
//Method:
- (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize usingImage:(UIImage *)image{
UIImage *sourceImage = image;
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>