步驟應該是:
獲取經緯度和長,並將它們設置爲兩個標籤,self.label1和self.label2
創建transparentColor背景空視圖。 2.
設置cameraOverlayView到視圖步驟第2步中
出示您的選擇器創建的視圖:
與addSubview添加標籤。
在代碼:
定義您的.h:CLLocationManager *locationManager
和落實代表:<CLLocationManagerDelegate>
- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; //How often do you want to update your location, this sets every small change should fire an update.
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
然後實現:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSString *lat = [NSString stringWithFormat:@"%d", newLocation.coordinate.latitude];
self.label1.text = lat;
NSString *long = [NSString stringWithFormat:@"%d", newLocation.coordinate.longitude];
self.label2.text = long;
}
那麼無論你想展示你的帶有座標的相機:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
emptyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //This frame will make it fullscreen...
emptyView.backgroundColor = [UIColor transparentColor];
[emptyView setAlpha:1.0]; //I think it is not necessary, but it wont hurt to add this line.
self.label1.frame = CGRectMake(100, 100, self.label1.frame.size.width, self.label1.frame.size.height); //Here you can specify the position in this case 100x 100y of your label1 preserving the width and height.
[emptyView addSubview:self.label1];
//Repeat for self.label2
self.picker.cameraOverlayView = emptyView; //Which by the way is not empty any more..
[emptyView release];
[self presentModalViewController:self.picker animated:YES];
[self.picker release];
希望它足夠清楚,沒有任何遺漏,因爲我沒有測試過這個。
我不知道我是否理解你的答案。知道用戶的位置,我必須告訴用戶正在尋找另一個位置。例如,我在紐約,我想知道自由女神像在哪裏。當用戶看時,我必須知道它的經緯度在屏幕上顯示。 – VansFannel
哦,我以爲你想覆蓋你的當前位置..你問的是更多的圖像識別軟件。 –