iPhone增强现实应用程序中的摄像头概述

iPhone增强现实应用程序中的摄像头概述,iphone,uiview,ios4,augmented-reality,Iphone,Uiview,Ios4,Augmented Reality,嘿,伙计们,我有以下简单的代码: 这里是miviewcontroller.h #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface WhereAmIViewController : UIViewController <CLLocationManagerDelegate> { CLLocationManager *locatio

嘿,伙计们,我有以下简单的代码: 这里是miviewcontroller.h

    #import <UIKit/UIKit.h>
    #import <CoreLocation/CoreLocation.h>

    @interface WhereAmIViewController : UIViewController <CLLocationManagerDelegate> {

        CLLocationManager *locationManager;
        CLLocation *startingPoint;
        IBOutlet UILabel *latitudeLabel;
        IBOutlet UILabel *longitudeLabel;
        IBOutlet UILabel *magneticHeading;
    }
    @property (retain, nonatomic) CLLocationManager *locationManager;
    @property (retain, nonatomic) CLLocation *startingPoint;
    @property (retain, nonatomic) UILabel *latitudeLabel;
    @property (retain, nonatomic) UILabel *longitudeLabel;
    @property (nonatomic, retain) UILabel *magneticHeading;

@end
这就是我在屏幕上显示的内容。。我只是想知道如何获得这3个标签作为相机的概述。我提到过 但和我一样有问题的是“基于视图的应用程序”,教程使用的是“基于Windows的应用程序”模板。。如何配置此代码以获取相机覆盖? 附言:背景色是:无色(透明)


谢谢大家!

您需要一个UIImagePickerController,然后创建一个UIView并在子视图中的适当位置添加3个标签,然后可以调用,
picker.cameraOverlayView=your\u UI\u VIEW
picker.showsCameraControls=NO
。如果您已经在WheremiViewController中设置了所有内容,则可以执行以下操作:picker.cameraOverlayView=WheremiVC.view

您需要一个UIImagePickerController,然后创建一个UIView,并在子视图中的适当位置添加3个标签,然后可以调用,
picker.cameraOverlayView=您的用户界面视图
picker.ShowScameraControl=否
。如果您已经在wheremiviewcontroller中设置了所有内容,那么您可以执行
picker.cameraoveryview=wheremivc.view

#import "WhereAmIViewController.h"

@implementation WhereAmIViewController
@synthesize locationManager;
@synthesize startingPoint;
@synthesize latitudeLabel;
@synthesize longitudeLabel;
@synthesize magneticHeading;


- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{

    NSString *magneticstring = [[NSString alloc] initWithFormat:@"%0.0f°",
                                newHeading.magneticHeading];
    magneticHeading.text = magneticstring;
    [magneticstring release];
}




#pragma mark -
-(void)viewDidLoad
{
    self.locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];
    [locationManager startUpdatingHeading];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [locationManager release];
    [startingPoint release];
    [latitudeLabel release];
    [longitudeLabel release];
    [super dealloc];
}
#pragma mark -
#pragma mark CLLocationManagerDelegate Methods
-(void)locationManager:(CLLocationManager *)manger
        didUpdateToLocation:(CLLocation *)newLocation
        fromLocation:(CLLocation *)oldLocation
{

    if(startingPoint == nil)
        self.startingPoint = newLocation;

    NSString *latitudeString = [[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.latitude];
    latitudeLabel.text = latitudeString;
    [latitudeString release];
    NSString *longitudeString = [[NSString alloc] initWithFormat:@"%g",newLocation.coordinate.longitude];
    longitudeLabel.text = longitudeString;
    [longitudeString release];

}

-(void)longitudeManager:(CLLocationManager *)manager
                         didFailWithError:(NSError *)error
{
                             NSString *errorType = (error.code ==kCLErrorDenied)?@"Access Denied":@"Unknown Error";
                             UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Error Getting Location!" message:errorType delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
                             [alert show];
                             [alert release];
}

@end