我正在创建一个用于拍照的自定义相机视图。这就是我所拥有的:
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
?
感谢。
答案 0 :(得分:3)
致电UIImagePickerController
的{{1}}。
takePicture
它将调用委托方法。