在应用程序启动时打开相机视图(iOS 6)

时间:2012-11-27 02:06:24

标签: iphone ios6 uiimagepickercontroller

我想要做的是让相机作为第一个屏幕打开应用程序。它不起作用,我不知道我失踪了什么。如果有人能填补我这将是美好的...谢谢。

    - (void)viewDidLoad
{


[super viewDidLoad];
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
    [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else
{
    [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}


}

1 个答案:

答案 0 :(得分:3)

试试这样。希望它可以帮到你:

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.delegate = self;

[self presentViewController:imagePicker animated:YES completion:nil];