开发者

Call didFinishPickingImage with custom camera button?

I am creating a custom camera view that I use to take a picture. Here is what I have:

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:UIControlStateNorm开发者_C百科al];
uploadImageButton.frame = CGRectMake(215, 435, 99, 42);
[vieww addSubview:uploadImageButton];

picker.cameraOverlayView = vieww;

Now how can I make cameraButton take the picture? with a addTarget:action? If so, how will it call the didFinishPickingImage?

Thanks.


Call UIImagePickerController's takePicture.

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

It will call the delegate method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜