Подтвердить что ты не робот

IPhone: предварительный просмотр камеры

Как добавить наложение (UIImageView) в предварительный просмотр камеры и ручка касается этого?

Мои предыдущие попытки сделать это (например, использовать UIImagePickerController и добавить изображение в качестве подвью) не удалось.

4b9b3361

Ответ 1

В этом руководстве объясняется следующее: http://www.musicalgeometry.com/?p=821

Просто добавьте UIImage в оверлейный вид вместо красной области, указанной в уроке.

Ответ 2

Для вашего файла реализации:

- (IBAction)TakePicture:(id)sender {

    // Create image picker controller
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

    // Set source to the camera
    imagePicker.sourceType =  UIImagePickerControllerSourceTypeCamera;

        // Delegate is self
        imagePicker.delegate = self;

        OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];     

        // Insert the overlay:
        imagePicker.cameraOverlayView = overlay;

       // Allow editing of image ?
        imagePicker.allowsImageEditing = YES;
        [imagePicker setCameraDevice:
        UIImagePickerControllerCameraDeviceFront];
        [imagePicker setAllowsEditing:YES];
        imagePicker.showsCameraControls=YES;
        imagePicker.navigationBarHidden=YES;
        imagePicker.toolbarHidden=YES;
        imagePicker.wantsFullScreenLayout=YES;

        self.library = [[ALAssetsLibrary alloc] init];

        // Show image picker
        [self presentModalViewController:imagePicker animated:YES];
    }

Создайте класс UIView и добавьте этот код

    - (id)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            // Initialization code


            // Clear the background of the overlay:
            self.opaque = NO;
            self.backgroundColor = [UIColor clearColor];

            // Load the image to show in the overlay:
            UIImage *overlayGraphic = [UIImage imageNamed:@"overlaygraphic.png"];
            UIImageView *overlayGraphicView = [[UIImageView alloc] initWithImage:overlayGraphic];
            overlayGraphicView.frame = CGRectMake(30, 100, 260, 200);
            [self addSubview:overlayGraphicView];

        }
        return self;
    }

Ответ 3

Возможно, вы можете добавить UIImageView в качестве подзадачи основного окна непосредственно вместо UIImagePicker, он может работать лучше. Просто не забудьте добавить их в правильном порядке или позвонить

[window bringSubviewToFront:imageView];

после того, как камера встала.

Если вы хотите обрабатывать штрихи на UIImageView, вы можете просто добавить UIImageView в качестве подсмотра обычного полноэкранного View с прозрачным фоном и добавить , который к окну вместо этого, с обычным подклассом UIViewController, который вы можете использовать для обработки событий касания.

Ответ 4

См. представление оверлей камеры (доступно в 3.1 и более поздних версиях)

@property(nonatomic, retain) UIView *cameraOverlayView