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
QPickOneView* myView = nil; | |
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"QPickOneView" owner:self options:nil]; | |
for (id currentObject in nibViews) { | |
if ([currentObject isKindOfClass:[QPickOneView class]]) { | |
myView = (QPickOneView *) currentObject; | |
break; | |
} | |
} |
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
#!/bin/sh | |
projectfile=`find -d . -name 'project.pbxproj'` | |
projectdir=`echo *.xcodeproj` | |
projectfile="${projectdir}/project.pbxproj" | |
tempfile="${projectdir}/project.pbxproj.out" | |
savefile="${projectdir}/project.pbxproj.mergesave" | |
cat $projectfile | grep -v "<<<<<<< HEAD" | grep -v "=======" | grep -v "^>>>>>>> " > $tempfile | |
cp $projectfile $savefile |
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
- (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality { | |
BOOL drawTransposed; | |
CGAffineTransform transform = CGAffineTransformIdentity; | |
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) { | |
// Apprently in iOS 5 the image is already correctly rotated, so we don't need to rotate it manually | |
drawTransposed = NO; | |
} else { | |
switch (self.imageOrientation) { | |
case UIImageOrientationLeft: |
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 <Foundation/Foundation.h> | |
@interface NSObject (Swizzle) | |
+ (void)swizzleInstanceSelector:(SEL)originalSelector | |
withNewSelector:(SEL)newSelector; | |
@end |
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
// 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> |
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
/* To call: | |
resizedImage = [self imageByScalingProportionallyToSize:myImageView.size usingImage:myImage]; | |
*/ | |
//Method: | |
- (UIImage *)imageByScalingProportionallyToSize:(CGSize)targetSize usingImage:(UIImage *)image{ | |
UIImage *sourceImage = image; |
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
// 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]; |
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
/* | |
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]; |
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
//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 ...... | |
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 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], |
OlderNewer