-(void)yourmethodname_clicked{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}
else{
UIAlertView *altnot=[[UIAlertView alloc]initWithTitle:@"Camera Not Available" message:@"Camera Not Available" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[altnot show];
[altnot release];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
MFMailComposeViewController *mailpicker = [[MFMailComposeViewController alloc] init];
[mailpicker.navigationBar setTintColor:[UIColor blackColor]];
mailpicker.mailComposeDelegate = self;
[mailpicker setSubject:@"set your subject"];
NSArray *toRecipients = [NSArray arrayWithObjects: nil];
[mailpicker setToRecipients:toRecipients];
UIImage *picture = [info objectForKey:@"UIImagePickerControllerOriginalImage"]];;
NSData *imageData = UIImagePNGRepresentation(picture);
[mailpicker addAttachmentData:imageData mimeType:@"image/png" fileName:@"set your file name"];
NSString *emailBody = @"set your body string";
[mailpicker setMessageBody:emailBody isHTML:YES];
[mailpicker setSubject:@"set your subject"];
mailpicker.title = @"Email";
[self presentModalViewController:mailpicker animated:YES];
[mailpicker release];
}
No comments:
Post a Comment