0

我正在尝试开发一个提供当前纬度和经度值的 iPhone 应用程序,但遇到了一些名为“未定义声明”的错误。你能帮我解决一下吗?提前致谢。

#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
4

1 回答 1

1

它应该是

return (toInterfaceOrientation == UIInterfaceOrientationPortrait); 
于 2013-03-20T23:38:19.710 回答