-2
如何採取一個iPhone應用程序的照片?
我可以使用哪些API?
請提供的示例代碼。
如何採取一個iPhone應用程序的照片?
我可以使用哪些API?
請提供的示例代碼。
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];
請在發佈新問題之前,搜索。這個問題是一個重複:HTTP://stackoverflow.com/questions/74113/access-the-camera-with-iphone-sdk – Moshe 2010-11-12 04:00:15
截圖應用程序或相機的照片? – raidfive 2010-11-12 06:01:54
重複:[使用iPhone SDK訪問相機](http://stackoverflow.com/questions/74113/access-the-camera-with-iphone-sdk) – Mario 2010-11-12 03:45:13