未定义的声明错误

时间:2013-03-20 23:17:07

标签: ios objective-c

我正在尝试开发一个提供当前纬度和经度值的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

1 个答案:

答案 0 :(得分:1)

应该是

return (toInterfaceOrientation == UIInterfaceOrientationPortrait);