开发者

iPhone SDK: Have UIView over camera display

How can I have a UIView开发者_C百科 over a view that contains a live view from the camera?


Put a NavigationController in uour MainWindow.xib, with a first Controller pointing to a custom CameraController (class attribute). Don't specify any XIB.

Keep a reference to this navigationController with an IBOutlet into your appDelegate, then call at laucnch :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

Create another xib for the overlay, with its controller, let's call it OverlayViewController.

Then into this CameraViewController :

.h

   @interface CameraController : UIViewController {
        UIImagePickerController* __picker;
        OverlayViewController* __overlay;
    }

@property (nonatomic, retain) UIImagePickerController* picker;
@property (nonatomic, retain) OverlayViewController* overlay;

.m

- (void) viewDidLoad {
    self.picker = [[UIImagePickerController alloc] init];
    self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;

    self.picker.showsCameraControls = NO;
    self.picker.navigationBarHidden = YES;
    self.picker.wantsFullScreenLayout = YES;

    // Insert the overlay
    self.overlay = [[OverlayViewController alloc] initWithNibName:@"Overlay" bundle:nil];
    self.overlay.pickerRef = self.picker;
    self.picker.cameraOverlayView = self.overlay.view;

    [self presentModalViewController:self.picker animated:NO];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜