2010-11-12 4 views
-2

Possible en double:
Access the camera with iPhone SDKComment faire une capture d'écran dans l'application iPhone?

Comment puis-je prendre une photo dans une application iPhone?

Quelle API puis-je utiliser?

Veuillez fournir un exemple de code.

+0

Veuillez faire une recherche avant de publier de nouvelles questions Cette question est une copie de: http: //stackoverflow.com/questions/74113/access-the-camera-with-iphone-sdk – Moshe

+0

capture d'écran de l'application ou photo de la caméra? – raidfive

+0

Dupliquer de: [Accéder à la caméra avec iPhone SDK] (http://stackoverflow.com/questions/74113/access-the-camera-with-iphone-sdk) – Mario

Répondre

2
UIGraphicsBeginImageContext(self.view.bounds.size); 

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *saveImage = UIGraphicsGetImageFromCurrentImageContext(); 
CGContextRef context = UIGraphicsGetCurrentContext(); 

UIImageWriteToSavedPhotosAlbum(saveImage, self, @selector(image:didFinishSavingWithError:contextInfo:), &context); 
UIGraphicsEndImageContext(); 

// saving image in documents folder 
NSData *imageData = UIImagePNGRepresentation(saveImage); 
NSString *imageName = @"temp.png"; 

NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString* documentsDirectory = [paths objectAtIndex:0]; 

NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName]; 
[imageData writeToFile:fullPathToFile atomically:NO]; 
Questions connexes