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
// Create a UITapGestureRecognizer and add it to the view | |
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; | |
tap.cancelsTouchesInView = NO; | |
[self.view addGestureRecognizer:tap]; | |
// In the handleTap Method add | |
- (void)handleTap:(UITapGestureRecognizer *)tap | |
{ | |
[self.view endEditing:YES]; | |
} |
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)handleLongPress:(UILongPressGestureRecognizer*)sender { | |
if (sender.state == UIGestureRecognizerStateEnded) { | |
NSLog(@"UIGestureRecognizerStateEnded"); | |
//Do Whatever You want on End of Gesture | |
} | |
else if (sender.state == UIGestureRecognizerStateBegan){ | |
NSLog(@"UIGestureRecognizerStateBegan."); | |
//Do Whatever You want on Began of Gesture | |
} | |
} |
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
// Link Against Assets Library | |
// #import <AssetsLibrary/AssetsLibrary.h> | |
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; | |
// Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos. | |
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) | |
{ | |
// Within the group enumeration block, filter to enumerate just photos. | |
[group setAssetsFilter:[ALAssetsFilter allPhotos]]; |
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
// setup a picker for the camera | |
UIImagePickerController *cameraController = [[UIImagePickerController alloc] init]; | |
cameraController.delegate = self; | |
cameraController.sourceType = UIImagePickerControllerSourceTypeCamera; | |
cameraController.allowsEditing = YES; | |
[self presentViewController:cameraController animated:YES 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
UIImagePickerController *libraryController = [[UIImagePickerController alloc] init]; | |
libraryController.delegate = self; | |
libraryController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; | |
libraryController.allowsEditing = YES; | |
// if on the ipad, show the library in a popover | |
if (iPad) | |
{ | |
UIPopoverController *libraryPopover = [[UIPopoverController alloc] initWithContentViewController:libraryController]; | |
[libraryPopover presentPopoverFromRect:self.rectToPresentPopoverFrom inView:self.scrollView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; |
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
#pragma mark - | |
#pragma mark UIImagePickerController Delegate Methods | |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info | |
{ | |
// dismiss the picker | |
if (self.popover) | |
{ | |
[self.popover dismissPopoverAnimated:YES]; | |
self.popover = 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
+ (<#Class#> *)sharedManager | |
{ | |
static <#Class#> *sharedManager = nil; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
sharedManager = [[<#Class#> alloc] init]; | |
// other initialisation stuff | |
}); | |
return sharedManager; | |
} |
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)restart:(id)sender | |
{ | |
NSString *restartScript = @"while ps -p $1 > /dev/null; do sleep 0.1; done; open \"$2\""; | |
NSArray *arguments = [NSArray arrayWithObjects: | |
@"-c", restartScript, | |
@"", | |
[NSString stringWithFormat:@"%d",[[NSProcessInfo processInfo] processIdentifier]], | |
[[NSBundle mainBundle] bundlePath], | |
nil]; | |
[NSTask launchedTaskWithLaunchPath:@"/bin/sh" arguments:arguments]; |
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 *)appNameAndVersionNumberDisplayString { | |
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; | |
NSString *appDisplayName = [infoDictionary objectForKey:@"CFBundleDisplayName"]; | |
NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; | |
NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"]; | |
return [NSString stringWithFormat:@"%@, Version %@ (%@)", | |
appDisplayName, majorVersion, minorVersion]; | |
} |
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
1) Choose the target you want to add to | |
2) Choose Build Settings | |
3) Search for 'macros' | |
4) Add a macro | |
To use the macro in the app: | |
#ifdef MACRO | |
// do some stuff | |
#elif OTHERMACRO | |
// do other stuff |
OlderNewer