我正在尝试创建一个简单的相机应用程序,其覆盖视图显示两个按钮和一个手势识别器。
目前,我有一个带有 .xib 文件的“OverlayViewController”,其中包含一个带有两个按钮和一个手势识别器的 UIView。
在我通过 UIImagePicker 在 viewDidLoad 上显示相机的 CameraViewController 中,我尝试将此选择器分配给我的叠加层,但到目前为止我没有得到叠加层中的任何按钮......
OverlayViewController.h
@interface OverlayViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIGestureRecognizerDelegate>
- (IBAction)take_picture:(UIButton *)sender;
- (IBAction)choose_picture:(UIButton *)sender;
@end
OverlayViewController.m - 几乎是空的(我需要在这里初始化 UIButtons 吗??)
CameraViewController.h
@interface ProfileViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIGestureRecognizerDelegate>
@property (strong, nonatomic) UIImagePickerController *picker;
@property (strong, nonatomic) OverlayViewController *overlay;
CameraViewController.m
-(void)setupCamera
{
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.overlay = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil];
// _overlay.delegate = self;
// NSArray* nibViews= [[NSBundle mainBundle] loadNibNamed:@"OverlayViewController" owner:self.overlay options:nil];
// UIView* uiView= [nibViews objectAtIndex:0];
// uiView.opaque= NO;
// uiView.backgroundColor= [UIColor clearColor];
self.picker.cameraOverlayView = self.overlay.view;
self.picker.delegate = self.overlay;
self.picker.showsCameraControls = NO;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;
self.picker.wantsFullScreenLayout = YES;
[self presentViewController:self.picker animated:NO completion:nil];
}
我也想知道哪个控制器应该是这些隐形按钮的代表......
我在这里先向您的帮助表示感谢!