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)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { | |
NSString *mediaType = info[UIImagePickerControllerMediaType]; | |
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) { | |
UIImage *image = [self scaleAndRotateImage:[info objectForKey:UIImagePickerControllerOriginalImage]]; | |
UIGraphicsBeginImageContextWithOptions(image.size, FALSE, 0.0); | |
[image drawInRect:CGRectMake( 0, 0, image.size.width, image.size.height)]; | |
[renderedImage.image drawInRect:CGRectMake( renderedImage.frame.origin.x - 40.0, renderedImage.frame.origin.y - 40.0, renderedImage.frame.size.width, renderedImage.frame.size.height)]; | |
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, 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
UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotate:)]; | |
[rotationRecognizer setDelegate:self]; | |
[renderedImage addGestureRecognizer:rotationRecognizer]; | |
- (void)handleRotate:(UIRotationGestureRecognizer *)recognizer { | |
recognizer.view.transform = CGAffineTransformRotate(recognizer.view.transform, recognizer.rotation); | |
recognizer.rotation = 0; | |
} |
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
UIGraphicsBeginImageContextWithOptions(myImage.frame.size, FALSE, 0.0); | |
CALayer* layer = myImage.layer; | |
[layer renderInContext:UIGraphicsGetCurrentContext()]; | |
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, 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
- (IBAction)getFacebookUserInfo:(id)sender { | |
NSArray *permissions = [NSArray arrayWithObjects:@"email", @"basic_info", nil]; | |
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) | |
{ | |
/* handle success + failure in block */ | |
if (!error) { | |
[self me]; | |
} else { | |
NSLog(@"Session ended"); | |
[self hideProgressHud]; |
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
#import <UIKit/UIKit.h> | |
#import "GlobalInstance.h" | |
@protocol BaseDelegate <NSObject> | |
@required | |
- (void)didSelectActionSheetIndex:(NSString *)actionTitle actionSheetIndex:(NSInteger )index; | |
@end |
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
// | |
// BaseViewController.m | |
// | |
// Created by Work on 22/09/14. | |
// Copyright (c) 2014 E. All rights reserved. | |
// | |
#import "BaseViewController.h" | |
#import "GlobalInstance.h" | |
#import "CDRTranslucentSideBar.h" |
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
#import <UIKit/UIKit.h> | |
#import "BaseViewController.h" | |
@interface FirstViewController : BaseViewController <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate, UIActionSheetDelegate> | |
... | |
@end |
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
// | |
// FirstViewController.m | |
// | |
// Created by Work on 19/09/14. | |
// Copyright (c) 2014 App. All rights reserved. | |
// | |
#import "FirstViewController.h" | |
@interface FirstViewController () <BaseDelegate> // Delegate |
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
CustomAction.h | |
-------------- | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@protocol BaseDelegate <NSObject> | |
@required | |
- (void)didSelectActionSheetIndex:(NSString *)actionTitle actionSheetIndex:(NSInteger )index; |
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
1. FirstViewController will show one ActionSheet and its action perform here by UIActionSheetDelegate. Before, presenting this action sheet i am setting the delegate to my CustomAction class | |
- (void)cellMenuClicked:(id)sender { | |
CustomAction *obj = [[CustomAction alloc] init]; | |
obj.delegate = self; | |
thumbActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:obj cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Add to Watchlist", @"Share", nil]; | |
[thumbActionSheet showInView:[self.view window]]; | |
} |
OlderNewer