This file contains hidden or 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)fixOrientationOfVideoAtURL:(NSURL *)videoURL { | |
AVAsset *firstAsset = [AVAsset assetWithURL:videoURL]; | |
if(firstAsset !=nil && [[firstAsset tracksWithMediaType:AVMediaTypeVideo] count]>0){ | |
//Create AVMutableComposition Object.This object will hold our multiple AVMutableCompositionTrack. | |
AVMutableComposition* mixComposition = [[AVMutableComposition alloc] init]; | |
//VIDEO TRACK | |
AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; | |
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration) ofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil]; |
This file contains hidden or 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 "Build Settings" ---> "User Headers Search Paths", | |
$(PROJECT_DIR) ... Recursive |
This file contains hidden or 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 git repo: | |
git init | |
Remove a git repo: | |
cd repository-path/ | |
rm -r .git | |
Check if directory is under git control: | |
git rev-parse --is-inside-work-tree |
This file contains hidden or 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)firePOSTMethod { | |
NSString *boundary = @"----WebKitFormBoundarycC4YiaUFwM44F6rT"; | |
// create request | |
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; | |
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; | |
[request setHTTPShouldHandleCookies:NO]; | |
[request setTimeoutInterval:30]; | |
[request setHTTPMethod:@"POST"]; |
This file contains hidden or 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
// rotate | |
[UIView animateWithDuration:0.25 animations:^{ | |
CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI/2); | |
viewObject.transform = transform; | |
}]; | |
// back to default position | |
[UIView animateWithDuration:0.25 animations:^{ | |
CGAffineTransform transform = CGAffineTransformMakeRotation(0); | |
viewObject.transform = transform; |
This file contains hidden or 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 *)getScreenshot { | |
UIGraphicsBeginImageContextWithOptions(imageView.frame.size, NO, 0.0); | |
[viewObject.layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *createdImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return createdImage; | |
} | |
Replace "viewObject" with the name of the view or image view you want to take a screenshot of. |
This file contains hidden or 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
CGRect contentRect = CGRectZero; | |
for (UIView *view in scrollViewObject.subviews) { | |
contentRect = CGRectUnion(contentRect, view.frame); | |
} | |
scrollViewObject.contentSize = contentRect.size; |
This file contains hidden or 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
// call "registerForKeyboardNotifications" to enable | |
- (void)registerForKeyboardNotifications { | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWasShown:) | |
name:UIKeyboardDidShowNotification object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillBeHidden:) | |
name:UIKeyboardWillHideNotification object:nil]; | |
} |