编辑 3
好消息和坏消息。好消息是,在 Connections Inspector 中,通过断开覆盖 UIToolbar 并连接 UIImageview,我看到了theKing
,但是 - 坏消息 - 我没有看到我也需要的 UIToolbar。所以现在的问题是,当他/她在这里完成后,用户如何才能回到调用的 VC?工具栏和图像如何成为覆盖的一部分,或者“返回按钮”工具栏可以在非覆盖视图上,还是什么?或者我怎样才能在 OverlayViewController 上同时显示工具栏和图像?
编辑 3
编辑 2
setupImagePicker
在OverlayViewController.m
.
- (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;
CGRect newFrame = CGRectMake(0.0,
CGRectGetHeight(overlayViewFrame) -
self.view.frame.size.height - 10.0,
CGRectGetWidth(overlayViewFrame),
self.view.frame.size.height + 10.0);
self.view.frame = newFrame;
[self.imagePickerController.cameraOverlayView addSubview:self.view];
}
}
}
编辑 2
编辑 1
编辑 1
编辑 0
有没有人在 iPhone 而不是 iPad 上试过这个?我没有 iPhone,但我今天正在阅读 Matt Neuburg 的书,他说 UIImagePicker 在这两种设备上的工作方式不同。
编辑 0
我在 UIImagePicker 中看不到我试图覆盖在相机视图中的图像。无论我如何添加 IBOutlet,作为属性,图像都不会显示,但覆盖的工具栏显示正常。为什么?
带有 IBOutlet 的 OverlayViewController.htheKing
添加到 Apple 的示例代码中,然后暂时注释掉。
#import <UIKit/UIKit.h>
#import <AudioToolbox/AudioServices.h>
@protocol OverlayViewControllerDelegate;
@interface OverlayViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
{
// IBOutlet UIImageView* theKing; ******** temporarily commented out
id <OverlayViewControllerDelegate> delegate;
}
@property (nonatomic, assign) id <OverlayViewControllerDelegate> delegate;
@property (nonatomic, retain) UIImagePickerController *imagePickerController;
- (void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType;
@end
@protocol OverlayViewControllerDelegate
- (void)didTakePicture:(UIImage *)picture;
- (void)didFinishWithCamera;
@end
property
在 Apple 的示例代码中添加了用于theKing
IBOutlet 的OverlayViewController.m 。
#import "OverlayViewController.h"
enum
{
kOneShot, // user wants to take a delayed single shot
kRepeatingShot // user wants to take repeating shots
};
@interface OverlayViewController ( )
@property (assign) SystemSoundID tickSound;
@property (nonatomic, retain) IBOutlet UIImageView* theKing; // added *********
@property (nonatomic, retain) IBOutlet UIBarButtonItem *takePictureButton;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *startStopButton;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *timedButton;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *cancelButton;
@property (nonatomic, retain) NSTimer *tickTimer;
@property (nonatomic, retain) NSTimer *cameraTimer;
theKing
在 iPhone 上执行代码时看不到图像。下面是我添加的笔尖视图,显示了一些连接。没有抛出错误,但我看不到图像,只有 UIToolbar 已经添加。