我有一個自定義的視圖控制器,我使用的是一對按鈕,一個拍照,一個選照片。當您選擇照片時,它會顯示相機膠捲沒有問題。但是,當您選擇拍照時,即使我使用的是具有完美功能的相機,它仍會顯示相機膠捲 - 或照片流或實際相機以外的任何其他相機。UIImagePickerController不會顯示相機,只有相機膠捲
- (IBAction)getPhoto:(id)sender
{
[self makeUIImagePickerControllerForCamera:NO];
}
- (IBAction)takePhoto:(id)sender
{
[self makeUIImagePickerControllerForCamera:YES];
}
- (void) makeUIImagePickerControllerForCamera:(BOOL)camera
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if (camera) {
NSLog(@"!!! Show camera");
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
[picker setMediaTypes:[NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil]];
[self presentModalViewController: picker animated: YES];
}
上面的代碼正是我使用的。不管怎樣,我只需要讓相機實際展示。謝謝!
*注意:我正在使用iOS 5和ARC。
你必須發佈picker btw。 – mbh
我正在使用ARC。 – zorz