通过UImagePickerController将摄像机视图添加到UIImageView

时间:2014-07-09 06:56:01

标签: ios ios7 uiimageview uiimagepickercontroller

我的代码就像在我的photo.h文件中一样:

@interface PhotoViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
{
    UIImageView *photoView;
    UIButton *choosePhotoButton;
    UIButton *takePhotoButton;
}

@property (strong, nonatomic) IBOutlet UIImageView *photoView;
@property (nonatomic, retain) IBOutlet UIButton *choosePhotoButton;
@property (nonatomic, retain) IBOutlet UIButton *takePhotoButton;

- (IBAction) selectPhoto:  (UIButton *)sender;
- (IBAction) takePhoto:(UIButton *)sender;

@end

在photo.m文件中,我打电话:

- (void) addPhotoView
{
    // Now add the photoView
    _photoView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 65.0, [self screenWidth], [self screenHeight] - 154.0)];
    // _photoView.backgroundColor = [UIColor whiteColor];

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
   picker.delegate = self;
   picker.allowsEditing = YES;
   picker.sourceType = UIImagePickerControllerSourceTypeCamera;

   [self presentViewController:picker animated:YES completion:NULL];

   [self.view addSubview:_photoView];
}

如何让我的_photoView成为相机的视图?

1 个答案:

答案 0 :(得分:0)

试试这个Open Camara on subview

我希望对我们有用