UIImagePickerController
オーバーレイビューを表示しようとしています。OverlayViewController's
ビューをサブビューとしてに追加していViewController
ます。しかし、アプリをデバイスにダンプすると、空白の画面が表示されます。
私のコードはここにあります:
ViewController.m
@interface ViewController ()
@property (nonatomic, retain) OverlayViewController *overlayViewController;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.overlayViewController =
[[[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:nil] autorelease];
// as a delegate we will be notified when pictures are taken and when to dismiss the image picker
self.overlayViewController.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
[self.overlayViewController setupImagePicker:UIImagePickerControllerSourceTypeCamera];
[self presentModalViewController:self.overlayViewController.imagePickerController animated:YES];
}
// Do any additional setup after loading the view, typically from a nib.
}
OverlayViewController.m
@interface OverlayViewController ()
@property (nonatomic, retain) IBOutlet UIButton *Capture;
@property (nonatomic, retain) IBOutlet UIButton *Library;
@property (nonatomic, retain) IBOutlet UIButton *ZoomOut;
@property (nonatomic, retain) IBOutlet UIButton *FrontCam;
@property (nonatomic, retain) IBOutlet UISlider *zoom;
@end
@implementation OverlayViewController
@synthesize delegate;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.imagePickerController = [[UIImagePickerController alloc] init];
self.imagePickerController.delegate = self;
}
return self;
}
- (void)dealloc
{
[_imagePickerController release];
[super dealloc];
}
- (void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType
{
self.imagePickerController.sourceType = sourceType;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
// user wants to use the camera interface
//
self.imagePickerController.showsCameraControls = NO;
if ([[self.imagePickerController.cameraOverlayView subviews] count] == 0)
{
// setup our custom overlay view for the camera
//
// ensure that our custom view's frame fits within the parent frame
CGRect overlayViewFrame = self.imagePickerController.cameraOverlayView.frame;
NSLog(@"Overlay view Frame heidgt is %f and width is %f", self.imagePickerController.cameraOverlayView.frame.size.height,self.imagePickerController.cameraOverlayView.frame.size.width);
CGRect newFrame = CGRectMake(0.0, 20.0, 320.0, 480.0);
NSLog(@"Overlay view Frame heidgt is %f and width is %f", self.view.frame.size.height,self.view.frame.size.width);
self.view.frame = newFrame;
[self.imagePickerController.cameraOverlayView addSubview:self.view];
}
}
}
これを行うために、 https://developer.apple.com/library/ios/#samplecode/PhotoPicker/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010196からサンプルコードをダウンロードしました。
いくつかのコントロール(キャプチャボタン、フラッシュボタンなど)を備えたカスタムビューを表示したいと思います。どうすればこれを達成できますか..?