Вызвать ли FinishPickingImage с помощью пользовательской кнопки камеры? - PullRequest
1 голос
/ 03 июня 2011

Я создаю собственный вид камеры, который я использую для съемки.Вот что у меня есть:

picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.navigationBarHidden = YES;
picker.toolbarHidden = YES;
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformMakeScale(1.25, 1.25);


// Create View
UIView *vieww = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[vieww setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
[vieww setBackgroundColor:[UIColor clearColor]];

// Create tcustom tab bar
UIImageView *tabBarBack = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tab_bar_back.png"]];
tabBarBack.frame = CGRectMake(0, 426, 320, 54);
[vieww addSubview:tabBarBack];

UIButton *cameraButton = [UIButton buttonWithType:UIButtonTypeCustom];
[cameraButton setBackgroundImage:[UIImage imageNamed:@"camera_icon_normal.png"] forState:UIControlStateNormal];
[cameraButton setBackgroundImage:[UIImage imageNamed:@"camera_icon_normal.png"] forState:UIControlStateDisabled];
[cameraButton setBackgroundImage:[UIImage imageNamed:@"camera_icon_normal_hit.png"] forState:UIControlStateSelected];
[cameraButton setBackgroundImage:[UIImage imageNamed:@"camera_icon_normal_hit.png"] forState:UIControlStateHighlighted];
cameraButton.frame = CGRectMake(114, 435, 99, 42);
[vieww addSubview:cameraButton];

UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
cancelButton.frame = CGRectMake(20, 435, 99, 42);
[vieww addSubview:cancelButton];

UIButton *uploadImageButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[uploadImageButton setTitle:@"Roll" forState:UIControlStateNormal];
uploadImageButton.frame = CGRectMake(215, 435, 99, 42);
[vieww addSubview:uploadImageButton];

picker.cameraOverlayView = vieww;

Теперь, как мне заставить cameraButton сделать снимок?с addTarget:action?Если так, как это будет называться didFinishPickingImage?

Спасибо.

1 Ответ

3 голосов
/ 03 июня 2011

Вызов UIImagePickerController takePicture.

[cameraButton addTarget:picker action:@selector(takePicture) forControlEvents:UIControlEventTouchUpInside];

Будет вызван метод делегата.

...