Reputation: 53
I am trying to develop an iPhone app that gives the current latitude and longitude values and am getting some error called "Undefined declaration".Can you please help me sorting it out. Thanks in advance.
#import "LoginViewController.h"
//#import <CoreLocation/CoreLocation.h>
@interface LoginViewController ()
@end
@implementation LoginViewController
@synthesize locationManager;
- (void)dealloc
{
// [super dealloc];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)Button:(id)sender
{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
NSString *latitude = [NSString stringWithFormat:@"%f", coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%f", coordinate.longitude];
NSLog(@"dLatitude : %@", latitude);
NSLog(@"dLongitude : %@", longitude);
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 40, 250, 50)];
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 80, 200, 50)];
UILabel *myLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(50, 120, 200, 100)];
myLabel.textColor = [UIColor blackColor];
myLabel1.textColor = [UIColor blackColor];
label.backgroundColor = [UIColor clearColor];
myLabel.backgroundColor = [UIColor clearColor];
myLabel1.backgroundColor = [UIColor clearColor];
[myLabel setText:latitude];
[myLabel1 setText:longitude];
label.text = @"Current Latitude and Longitude";
[self.view addSubview:label];
[self.view addSubview:myLabel];
[self.view addSubview:myLabel1];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait); <---GETTING ERROR HERE
}
@end
Upvotes: 0
Views: 93
Reputation: 11436
It should be
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
Upvotes: 1