How to determine if ios user is signed in to twitter? - iphone

I want to determine it a user is signed on to twitter, so I can prompt them to post a tweet but only if they are set up with ios and twitter. Also, is there a way to set up the twitter screen with a default tweet?

For iOS 5.x, you can check if the user is signed in to twitter using:
[TWTweetComposeViewController canSendTweet]
As for presenting a tweet screen with default message, you can do something like:
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:defaultMsg];
[self presentModalViewController:tweetSheet animated:YES];
You can refer this tutorial for more.
EDIT: For iOS 6.0 and above, use:
// requires "Social.framework"
[SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]
So, an example usage could be:
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){
[controller dismissViewControllerAnimated:YES completion:Nil];
};
controller.completionHandler = myBlock;
[controller setInitialText:#"#myHashTag"];
[controller addImage:myImage];
[self presentViewController:controller animated:YES completion:Nil];
}
else
{ /* Show error alert, etc*/ }
Further reading

As I said in my comment if you are using IOS 5 or later versions just add Twitter.framework to your projects
#import <Twitter/Twitter.h>
//post tweets
- (IBAction)postTapped:(id)sender{
if ([TWTweetComposeViewController canSendTweet])
{
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:#" #hashtag"];
[self presentModalViewController:tweetSheet animated:YES];
}
else
{
TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc] init];
//hide the tweet screen
viewController.view.hidden = YES;
//fire tweetComposeView to show "No Twitter Accounts" alert view on iOS5.1
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
if (result == TWTweetComposeViewControllerResultCancelled) {
[self dismissModalViewControllerAnimated:NO];
}
};
[self presentModalViewController:viewController animated:NO];
//hide the keyboard
[viewController.view endEditing:YES];
}
}

Related

Viewcontroller not appearing since iOS7

Edit - I solved this myself - see the notes at the bottom
When using iOS7 on Xcode 5, I am using an option to take an image from a camera, or from the photo library, once the image is chosen (or a new picture taken) the view should flip over to the next screen.
This does not happen on the iPhone running iOS7, it works fine on the iPad, but the method is slightly different, but it does appear to be iPhone only problem on iOS7.
here is the code used, for example, on the choose image from library function;
-(void) choosePic {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
_popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
[_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else
[self presentModalViewController: cameraUI animated: YES];
}
}
Also, the code once picker is finished;
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info {
//Disable buttons
[[UIApplication sharedApplication] setStatusBarHidden:YES];
[self disableButtons];
//Get image
self.originalImage = (UIImage *) [info objectForKey: UIImagePickerControllerOriginalImage];
//Dismiss
if(_popover)
{
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
[_popover dismissPopoverAnimated:YES];
_popover = nil;
}
}
else
[picker dismissModalViewControllerAnimated: YES];
//Next
[self performSelector: #selector(nextScreen) withObject:nil afterDelay:0.5];
}
I fixed this by switching out;
[picker dismissModalViewControllerAnimated: YES];
With
[picker dismissViewControllerAnimated:NO completion:nil];
First you need to make sure that logic reaches the correct place it's intended to, try setting a breakpoint or NSLog before the iPhone's specific line, try this (You also missed curled braces, added them here) :
-(void) choosePic {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
cameraUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum];
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
_popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
[_popover presentPopoverFromRect:btnLibrary.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}else{
NSLog(#"Checkpoint !");
[self presentModalViewController: cameraUI animated: YES];
}
} }

How do i post the current app screen to the Facebook and Twitter sheets using SLRequests in iOS6

I have integrated the below code for the Facebook and Twitter buttons.
I currently have test images there to post in the social media sheets - however i want to post the current app screen not a pre determined image as the screen changes all the time.
What can i do?
- (IBAction)postToTwitter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Test Run!"];
if (![tweetSheet addImage:[UIImage imageNamed:#"test1.jpg"]]) {
NSLog(#"Unable to add the image!");
}
if (![tweetSheet addURL:[NSURL URLWithString:#"http://twitter.com/"]]){
NSLog(#"Unable to add the URL!");
}
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}
- (IBAction)postToFacebook:(id)sender {
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"Test Run"];
[controller addURL:[NSURL URLWithString:#""]];
[controller addImage:[UIImage imageNamed:#"test2.jpg"]];
[self presentViewController:controller animated:YES completion:Nil];
}

iOS - EXC_BAD_ACCESS when executing a segue to MPMoviePlayerViewController

I am using Storyboard-
I am pretty new to this-
I'm getting a EXC_BAD_ACCESS (code=2, address = 0x4) error when I click a button pointing to a MPMoviePlayerViewController.
To give you an idea of what I've got so far: I have several different ViewControllers all under the same ViewController.h/m class with navigation controlled by a NavigationController. I started with a NavController and single ViewController and have been linking new ViewControllers with the simple CTRL-Click button-to-new-ViewController. I added a new ViewController; changed it's class to MPMoviePlayerViewController in the Custom Class section of the Identity Inspector, but I keep getting this error when I click on the button to begin the transition.
Here's my ViewController.h code if it's relevant:
- (IBAction)postToTwitter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:#"Check this out!"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}
- (IBAction)postToFacebook:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:#"Posted from IOS App Test -- It works!"];
[self presentViewController:controller animated:YES completion:Nil];
}
}
- (IBAction)playVideo1:(id)sender {
NSURL * url = [[NSURL alloc]initWithString:#"link omitted"];
//create our moviePlayer
moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
//Some additional customization
moviePlayer.fullscreen = YES;
moviePlayer.allowsAirPlay = YES;
moviePlayer.shouldAutoplay = NO;
moviePlayer.controlStyle = MPMovieControlStyleDefault;
}

Cocos2d:App crashing after closing mail composer view

In my app i am having 7 button i am show 3 button in that view after pressing down arrow it show other 3 button
1.Facebook share
2.twitter share
3.tell a friend
4.report
5.starter guide
6.visit my web site
7. feed back
LIKE THIS MY VIEW
====================
^ ---->up arrow
facebook share
Twitter share
Tell a friend
V ---->down arrow
i am using mailcomposerview for "tell a friend" button and "report" button
when i press "Tell a Friend" or "report" button it opens mailcomposerview after closing that i am not able to move the up and down arrow......if i press the up and down arrow it open the same mail composerview,its also not opening facebook share and twitter share
please help me to fix this issue
my coding when arrow pressed
-(void)arrTapped1:(id)sender
{
CCMenuItem *item2=(CCMenuItem*)sender;
int k=item2.tag;
////CCLOG(#"k tapp=%dhelp=%d",k,helpVal);
NSLog(#"HelpVal%i",helpVal);
if(k==51)
{
if(helpVal<3)
{
id action1=[CCMoveBy actionWithDuration:0.3 position:ccp(0,+260)];
id callfun1=[CCCallFunc actionWithTarget:self selector:#selector(enabled1) ];
[item2 setIsEnabled:YES];
[(CCSprite*)[self getChildByTag:10] runAction:[CCSequence actions:action1,callfun1,nil]];
[self performSelector:#selector(downWardsMove)];
}
}
else //if(k==50)
{
if(helpVal>1)
{
id action1=[CCMoveBy actionWithDuration:0.3 position:ccp(0,-260)];
id callfun1=[CCCallFunc actionWithTarget:self selector:#selector(enabled1) ];
[item2 setIsEnabled:YES];
[(CCSprite*)[self getChildByTag:10] runAction:[CCSequence actions:action1,callfun1,nil]];
[self performSelector:#selector(upWardsMove)];
} } }
//code for upwards & downwards move
//--------------------------------
-(void)upWardsMove
{
[upArrItem setIsEnabled:NO];
[downArrItem setIsEnabled:NO];
self.isTouchEnabled=NO;
helpVal--;
[(CCMenu*)[self getChildByTag:53] setVisible:YES];
[downArrItem setIsEnabled:YES];
if(helpVal==1)
{
[(CCMenu*)[self getChildByTag:52] setVisible:NO];
[upArrItem setIsEnabled:NO];
}
}
-(void)downWardsMove
{
[upArrItem setIsEnabled:NO];
[downArrItem setIsEnabled:NO];
self.isTouchEnabled=NO;
helpVal++;
[(CCMenu*)[self getChildByTag:52] setVisible:YES];
[upArrItem setIsEnabled:YES];
if(helpVal==3){
[(CCMenu*)[self getChildByTag:53] setVisible:NO];
[downArrItem setIsEnabled:NO];
}
}
-(void)enabled1
{
self.isTouchEnabled=YES;
[upArrItem setIsEnabled:YES];
[downArrItem setIsEnabled:YES];
if(helpVal==3)
{
[(CCMenu*)[self getChildByTag:53] setVisible:NO];
[downArrItem setIsEnabled:NO];
}
if(helpVal==1)
{
[(CCMenu*)[self getChildByTag:52] setVisible:NO];
[upArrItem setIsEnabled:NO];
}
}
//sending mail code
//------------------
-(void)sendMail
{
mailComposer = [[UIViewController alloc] init];
[[[CCDirector sharedDirector] openGLView] addSubview:mailComposer.view];
MFMailComposeViewController *mailController= [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:msgSubject];
[mailController setMessageBody:mailContent isHTML:YES];
NSArray *toRecipients = [NSArray arrayWithObject:#"Info#ask.com"];
[mailController setBccRecipients:toRecipients];
[mailComposer presentModalViewController:mailController animated:NO];
mailComposer.view.transform = CGAffineTransformMakeRotation( CC_DEGREES_TO_RADIANS(90.0f ) );
[mailController release];
[[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight]
}
-(void)mailComposeController:(MFMailComposeViewController*)mailController didFinishWithResult: (MFMailComposeResult)result error:(NSError*)error
{
[mailComposer dismissModalViewControllerAnimated:YES];
}
Here is a part of a code that I used in my apps and it works well in iOS 4.0 - iOS 6.0. Take a look:
-(void)sendMessageToEmail:(NSString *)message withSubject:(NSString *)subject
{
if([self _isIOS6andHigher]) {
NSArray *activities = #[message];
UIActivityViewController *viewController = [[UIActivityViewController alloc] initWithActivityItems:activities applicationActivities:nil];
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[app navController] presentViewController:viewController animated:YES completion:nil];
[viewController release];
} else {
MFMailComposeViewController* mailController = [[MFMailComposeViewController alloc] init];
mailController.mailComposeDelegate = self;
[mailController setSubject:subject];
[mailController setMessageBody:message isHTML:NO];
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
[[app navController] presentModalViewController:mailController animated:YES];
[mailController release];
}
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
[controller dismissModalViewControllerAnimated:YES];
}
You never release mailComposer:
mailComposer = [[UIViewController alloc] init];
This might cause it to leak and remain active as a view. That could explain the lack of touch events because mail composer might still intercept touches.

Selecting image on iPad

I'm trying to write code to select an image from the photo library on an iPad. The code that I'm using is below (taken from Apple's website), but it keeps giving me an error saying that On iPad, UIImagePickerController must be presented via UIPopoverController. I've tried changing this line: UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init]; to use a UIPopoverController, but obviously I'm doing something wrong because its not working.
- (BOOL) selectImage: (UIViewController*) controller
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) delegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO)
|| (delegate == nil)
|| (controller == nil))
return NO;
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
// Displays saved pictures and movies, if both are available, from the
// Camera Roll album.
mediaUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeSavedPhotosAlbum];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
mediaUI.allowsEditing = NO;
mediaUI.delegate = delegate;
[controller presentModalViewController: mediaUI animated: YES];
return YES; }
The Apple Developer page also says: "On iPad, you can alternatively present the browser interface using a popover as described in initWithContentViewController: and “Presenting and Dismissing the Popover” in UIPopoverController Class Reference." I've read it but I still can't get it to work. Any help would be appreciated.
Something like this should work:
// create an image picker controller
UIImagePickerController *imagePickerController = [[[UIImagePickerController alloc] init] autorelease];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
imagePickerController.delegate = self;
// present it in a popover
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:imagePickerController] autorelease];
self.popoverController.delegate = self;
// I was presenting the popover from a button, but you would set the rect to whatever is appropriate for your app
[self.popoverController presentPopoverFromRect:((UIButton *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Declare an ivar such as:
UIPopoverController *imagePopover;
Then:
imagePopover = [[UIPopoverController alloc] initWithContentViewController:mediaUI];
[imagePopover setDelegate:self];
[imagePopover presentPopoverFromRect:someRect
inView:someView
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
in place of
[controller presentModal...];
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 400.0, 400.0)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
refer below link
http://www.techotopia.com/index.php/An_Example_iOS_4_iPad_Camera_and_UIImagePickerController_Application_%28Xcode_4%29
I went through a lot of pain coming up with a solution which works on both iPad and iPhone, this is the final code which some of it comes from comments of other people:
the code has some bugs but it's a very good place to start :)
it covers permissions needed as well as how to manage viewcontrollers popoing up on ipad.
requires following imports :
#import <AVFoundation/AVFoundation.h>
#import <AssetsLibrary/AssetsLibrary.h>
and add this delegates :
UIActionSheetDelegate, UIImagePickerControllerDelegate
definitions :
__weak IBOutlet UIButton *attachButton;
UIImage *image;
button's action :
- (IBAction)doAttach:(id)sender {
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:#"Select image from" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"From library",#"From camera", nil] ;
[action showInView:self.view];
}
#pragma mark - ActionSheet delegates
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if( buttonIndex == 1 ) {
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if(authStatus == AVAuthorizationStatusAuthorized)
{
NSLog(#"%#", #"You have camera access");
}
else if(authStatus == AVAuthorizationStatusDenied)
{
NSLog(#"%#", #"Denied camera access");
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if(granted){
NSLog(#"Granted access to %#", AVMediaTypeVideo);
} else {
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“no camera access“
message: #“if you need to use camera in this application go to settings -> appName -> and turn on camera.”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
NSLog(#"Not granted access to %#", AVMediaTypeVideo);
return ;
}
}];
}
else if(authStatus == AVAuthorizationStatusRestricted)
{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“no camera access“
message: #“if you need to use camera in this application go to settings -> appName -> and turn on camera.”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
NSLog(#"%#", #"Restricted, normally won't happen");
}
else if(authStatus == AVAuthorizationStatusNotDetermined)
{
NSLog(#"%#", #"Camera access not determined. Ask for permission.");
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if(granted){
NSLog(#"Granted access to %#", AVMediaTypeVideo);
} else {
NSLog(#"Not granted access to %#", AVMediaTypeVideo);
return ;
}
}];
}
else
{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“No camera access“
message: #“error accusing camera”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
return;
//NSLog(#"%#", #"Camera access unknown error.");
}
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *pickerView =[[UIImagePickerController alloc]init];
pickerView.allowsEditing = YES;
pickerView.delegate = self;
pickerView.sourceType = UIImagePickerControllerSourceTypeCamera;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[ self.presentedViewController dismissViewControllerAnimated:YES completion:nil ];
pickerView.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popPC = pickerView.popoverPresentationController;
popPC.sourceView = attachButton;
popPC.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:pickerView animated:YES completion:nil];
} else {
[self presentModalViewController:pickerView animated:YES ];
}
}
}else if( buttonIndex == 0 ) {
ALAuthorizationStatus status = [ALAssetsLibrary authorizationStatus];
switch (status) {
case ALAuthorizationStatusRestricted:
case ALAuthorizationStatusDenied:
{
[self.presentedViewController dismissViewControllerAnimated:YES completion:nil];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:#“no access to library”
message: #“if you wish to access photos in this app go to settings -> appName-> and turn on photos .”
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:#“ok” style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
}
break;
default:
{
UIImagePickerController *pickerView = [[UIImagePickerController alloc] init];
pickerView.allowsEditing = YES;
pickerView.delegate = self;
[pickerView setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[ self.presentedViewController dismissViewControllerAnimated:YES completion:nil ];
pickerView.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popup = pickerView.popoverPresentationController;
popup.sourceView = attachButton;
popup.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:pickerView animated:YES completion:nil];
} else {
[self presentModalViewController:pickerView animated:YES ];
}
}
break;
}
}
}
#pragma mark - PickerDelegates
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissModalViewControllerAnimated:true];
UIImage * img = [info valueForKey:UIImagePickerControllerEditedImage];
image = img;
}