Objective-C 类参考:符号未找到错误
我已经在这个 iPhone 应用程序上工作了一段时间了,我已经完全完成并可以使用它了。我正在扩展的项目是从在线颠覆存储库下载的,我的教授也给了我访问权限。我不小心没有下载“根”副本或类似的东西,所以我无法向存储库提交任何更改。在老师的帮助下,我今天下载了根副本并将所有课程文件添加到其中,以便我可以提交更改。然而,我现在遇到了 3 个以前从未见过的奇怪错误:
未定义的符号:
“_OBJC_CLASS_$_mapListViewController”, 参考自: objc-class-ref-to-mapListViewController 在mapViewController.o中
“_OBJC_CLASS_$_mapParser”, 参考自: mapViewController.o 中的 objc-class-ref-to-mapParser
“_OBJC_CLASS_$_mapTabViewController”, 参考自: objc-class-ref-to-mapTabViewController 在mapViewController.o中
ld:未找到符号collect2:ld 返回 1 退出状态
这就是我收到的确切错误消息。我没有从今天早上完全运行的版本中更改任何代码。有什么建议吗? mapViewController 文件似乎是导致问题的原因,所以这也是:
#import "mapViewController.h"
#import "locationDetailViewController.h"
#import "DPUAnnotation.h"
#import "mapParser.h"
#import "mapListViewController.h"
#import "mapTabViewController.h"
@implementation mapViewController
@synthesize locationManager, mapView, mapAnnotations, mParser, mapListView, tabView;
@class DPUAnnotation;
+ (CGFloat)annotationPadding;
{
return 10.0f;
}
+ (CGFloat)calloutHeight;
{
return 40.0f;
}
- (void)gotoLocation
{
// start off by default at DePauw campus
MKCoordinateRegion newRegion;
newRegion.center.latitude = 39.639348;
newRegion.center.longitude = -86.861231;
newRegion.span.latitudeDelta = 0.006776;
newRegion.span.longitudeDelta = 0.006291;
[self.mapView setRegion:newRegion animated:YES];
}
- (void)viewDidLoad {
self.title = @"Map";
mapView.mapType = MKMapTypeHybrid;
mapView.showsUserLocation = YES;
mapListView = [[mapListViewController alloc] initWithNibName:@"mapListView" bundle:nil];
tabView = [[mapTabViewController alloc] initWithNibName:@"mapTabViewController" bundle:nil];
if (mapAnnotations == nil)
{
self.mapAnnotations = [NSMutableArray array];
}
else
{
[mapAnnotations removeAllObjects];
}
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn_home.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(mainpageClicked)];
[self.navigationItem setLeftBarButtonItem:backButton];
UIBarButtonItem *mapListButton = [[UIBarButtonItem alloc] initWithTitle:@"Building List" style:UIBarButtonItemStylePlain target:self action:@selector(pushMapList)];
[self.navigationItem setRightBarButtonItem: mapListButton];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
[self gotoLocation];
self.mParser = [[[mapParser alloc] init] autorelease];
self.mParser.delegate = self;
[self.mParser start];
[super viewDidLoad];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:(BOOL)animated];
}
- (void)dealloc
{
[mapView release];
[locationManager release];
[mapAnnotations release];
[super dealloc];
}
/*
* Returns the User to the main Application Page
*/
- (IBAction)mainpageClicked
{
NSLog(@"Return To Main page Clicked");
[self.parentViewController dismissModalViewControllerAnimated:YES];
[self.navigationController release];
}
- (IBAction) pushMapList
{
tabView = [[mapTabViewController alloc] initWithNibName:@"mapTabViewController" bundle:nil];
tabView.mapAnnotations2 = mapAnnotations;
[self.navigationController pushViewController:tabView animated:YES];
[tabView release];
}
- (IBAction)addAnnotation
{
[self.mapView removeAnnotations:self.mapView.annotations];
for (int i = 0; i < [mapAnnotations count]; i++)
[mapView addAnnotation:[mapAnnotations objectAtIndex:i]];
NSLog(@"BLAH BLAH BLAH PLEASE PRINT");
if([mapAnnotations count] == 0)
NSLog(@"array is empty");
}
- (void)showDetails:(id)sender
{
NSInteger selectedIndex = [sender tag];
DPUAnnotation *selectedObject = [mapAnnotations objectAtIndex:selectedIndex];
[self.navigationController setToolbarHidden:YES animated:NO];
NSURL *url = [NSURL URLWithString: selectedObject.url];
locationDetailViewController *locationDetailView;
locationDetailView = [[locationDetailViewController alloc] initWithNibName:@"mapDetailView" bundle:nil];
[self.navigationController pushViewController:locationDetailView animated:YES];
[locationDetailView.webView loadRequest: [NSURLRequest requestWithURL:url]];
[locationDetailView release];
[selectedObject release];
}
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
// if it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
if([[annotation subtitle] isEqualToString:@"Academic"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *academicImage = [UIImage imageNamed:@"academic.png"];
CGRect resizeRect;
resizeRect.size = academicImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[academicImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Administrative"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *administrativeImage = [UIImage imageNamed:@"administrative.png"];
CGRect resizeRect;
resizeRect.size = administrativeImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[administrativeImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"University Housing"] || [[annotation subtitle] isEqualToString:@"Residence Halls"] || [[annotation subtitle] isEqualToString:@"University Duplexes"] || [[annotation subtitle] isEqualToString:@"Greek Housing"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *housingImage = [UIImage imageNamed:@"housing.png"];
CGRect resizeRect;
resizeRect.size = housingImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[housingImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Other"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *otherImage = [UIImage imageNamed:@"other.png"];
CGRect resizeRect;
resizeRect.size = otherImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[otherImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Fields"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *athleticsImage = [UIImage imageNamed:@"athletics.png"];
CGRect resizeRect;
resizeRect.size = athleticsImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[athleticsImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Landmarks"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *landmarkImage = [UIImage imageNamed:@"landmark.png"];
CGRect resizeRect;
resizeRect.size = landmarkImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[landmarkImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
return nil;
}
#pragma mark <mapParser> Implementation
- (void)parser:(NSXMLParser *)parser didFailWithError:(NSError *)parseError {
}
- (void)parserDidEndParsingData:(mapParser *)parser
{
[self addAnnotation];
tabView.mapAnnotations2 = mapAnnotations;
self.mParser = nil;
[mParser release];
}
- (void)parser:(mapParser *)parser didParseItem:(NSArray *)parsedItem
{
NSLog(@"Did Parse Map Item");
[self.mapAnnotations addObjectsFromArray:parsedItem];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {}
@end
I've been working on this iPhone app for a while now, and I had it completely finished and working. The project I was expanding on was downloaded from a subversion repository online that my professor had given me access too. I accidentally didn't download the "root" copy or something like that, so I wasn't able to commit any changes to the repository. With my instructors help, I downloaded the root copy today and added all my class files to it so I could commit the changes. However, I am now getting 3 strange errors that I have never seen before:
Undefined symbols:
"_OBJC_CLASS_$_mapListViewController",
referenced from:
objc-class-ref-to-mapListViewController
in mapViewController.o"_OBJC_CLASS_$_mapParser",
referenced from:
objc-class-ref-to-mapParser in mapViewController.o"_OBJC_CLASS_$_mapTabViewController",
referenced from:
objc-class-ref-to-mapTabViewController
in mapViewController.old: symbol(s) not found collect2: ld
returned 1 exit status
That is the exact error message I am getting. I have not changed any code from the version that was working completely earlier this morning. Any advice? The mapViewController file seems to be what is causing the issue, so here is that as well:
#import "mapViewController.h"
#import "locationDetailViewController.h"
#import "DPUAnnotation.h"
#import "mapParser.h"
#import "mapListViewController.h"
#import "mapTabViewController.h"
@implementation mapViewController
@synthesize locationManager, mapView, mapAnnotations, mParser, mapListView, tabView;
@class DPUAnnotation;
+ (CGFloat)annotationPadding;
{
return 10.0f;
}
+ (CGFloat)calloutHeight;
{
return 40.0f;
}
- (void)gotoLocation
{
// start off by default at DePauw campus
MKCoordinateRegion newRegion;
newRegion.center.latitude = 39.639348;
newRegion.center.longitude = -86.861231;
newRegion.span.latitudeDelta = 0.006776;
newRegion.span.longitudeDelta = 0.006291;
[self.mapView setRegion:newRegion animated:YES];
}
- (void)viewDidLoad {
self.title = @"Map";
mapView.mapType = MKMapTypeHybrid;
mapView.showsUserLocation = YES;
mapListView = [[mapListViewController alloc] initWithNibName:@"mapListView" bundle:nil];
tabView = [[mapTabViewController alloc] initWithNibName:@"mapTabViewController" bundle:nil];
if (mapAnnotations == nil)
{
self.mapAnnotations = [NSMutableArray array];
}
else
{
[mapAnnotations removeAllObjects];
}
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn_home.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(mainpageClicked)];
[self.navigationItem setLeftBarButtonItem:backButton];
UIBarButtonItem *mapListButton = [[UIBarButtonItem alloc] initWithTitle:@"Building List" style:UIBarButtonItemStylePlain target:self action:@selector(pushMapList)];
[self.navigationItem setRightBarButtonItem: mapListButton];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
[self gotoLocation];
self.mParser = [[[mapParser alloc] init] autorelease];
self.mParser.delegate = self;
[self.mParser start];
[super viewDidLoad];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:(BOOL)animated];
}
- (void)dealloc
{
[mapView release];
[locationManager release];
[mapAnnotations release];
[super dealloc];
}
/*
* Returns the User to the main Application Page
*/
- (IBAction)mainpageClicked
{
NSLog(@"Return To Main page Clicked");
[self.parentViewController dismissModalViewControllerAnimated:YES];
[self.navigationController release];
}
- (IBAction) pushMapList
{
tabView = [[mapTabViewController alloc] initWithNibName:@"mapTabViewController" bundle:nil];
tabView.mapAnnotations2 = mapAnnotations;
[self.navigationController pushViewController:tabView animated:YES];
[tabView release];
}
- (IBAction)addAnnotation
{
[self.mapView removeAnnotations:self.mapView.annotations];
for (int i = 0; i < [mapAnnotations count]; i++)
[mapView addAnnotation:[mapAnnotations objectAtIndex:i]];
NSLog(@"BLAH BLAH BLAH PLEASE PRINT");
if([mapAnnotations count] == 0)
NSLog(@"array is empty");
}
- (void)showDetails:(id)sender
{
NSInteger selectedIndex = [sender tag];
DPUAnnotation *selectedObject = [mapAnnotations objectAtIndex:selectedIndex];
[self.navigationController setToolbarHidden:YES animated:NO];
NSURL *url = [NSURL URLWithString: selectedObject.url];
locationDetailViewController *locationDetailView;
locationDetailView = [[locationDetailViewController alloc] initWithNibName:@"mapDetailView" bundle:nil];
[self.navigationController pushViewController:locationDetailView animated:YES];
[locationDetailView.webView loadRequest: [NSURLRequest requestWithURL:url]];
[locationDetailView release];
[selectedObject release];
}
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
// if it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
if([[annotation subtitle] isEqualToString:@"Academic"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *academicImage = [UIImage imageNamed:@"academic.png"];
CGRect resizeRect;
resizeRect.size = academicImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[academicImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Administrative"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *administrativeImage = [UIImage imageNamed:@"administrative.png"];
CGRect resizeRect;
resizeRect.size = administrativeImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[administrativeImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"University Housing"] || [[annotation subtitle] isEqualToString:@"Residence Halls"] || [[annotation subtitle] isEqualToString:@"University Duplexes"] || [[annotation subtitle] isEqualToString:@"Greek Housing"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *housingImage = [UIImage imageNamed:@"housing.png"];
CGRect resizeRect;
resizeRect.size = housingImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[housingImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Other"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *otherImage = [UIImage imageNamed:@"other.png"];
CGRect resizeRect;
resizeRect.size = otherImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[otherImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Fields"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *athleticsImage = [UIImage imageNamed:@"athletics.png"];
CGRect resizeRect;
resizeRect.size = athleticsImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[athleticsImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
else if([[annotation subtitle] isEqualToString:@"Landmarks"])
{
// try to dequeue an existing pin view first
static NSString* annotationIdentifier = @"annotationIdentifier";
MKPinAnnotationView* pinView = (MKPinAnnotationView *)[theMapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!pinView)
{
MKAnnotationView *annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:annotationIdentifier] autorelease];
annotationView.canShowCallout = YES;
UIImage *landmarkImage = [UIImage imageNamed:@"landmark.png"];
CGRect resizeRect;
resizeRect.size = landmarkImage.size;
CGSize maxSize = CGRectInset(self.view.bounds,
[mapViewController annotationPadding],
[mapViewController annotationPadding]).size;
maxSize.height -= self.navigationController.navigationBar.frame.size.height + [mapViewController calloutHeight];
if (resizeRect.size.width > maxSize.width)
resizeRect.size = CGSizeMake(maxSize.width, resizeRect.size.height / resizeRect.size.width * maxSize.width);
if (resizeRect.size.height > maxSize.height)
resizeRect.size = CGSizeMake(resizeRect.size.width / resizeRect.size.height * maxSize.height, maxSize.height);
resizeRect.origin = (CGPoint){0.0f, 0.0f};
UIGraphicsBeginImageContext(resizeRect.size);
[landmarkImage drawInRect:resizeRect];
UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
annotationView.image = resizedImage;
annotationView.opaque = NO;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
NSInteger annotationValue = [self.mapAnnotations indexOfObject:annotation];
rightButton.tag = annotationValue;
[rightButton addTarget:self action:@selector(showDetails:) forControlEvents:UIControlEventTouchUpInside];
annotationView.rightCalloutAccessoryView = rightButton;
return annotationView;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
return nil;
}
#pragma mark <mapParser> Implementation
- (void)parser:(NSXMLParser *)parser didFailWithError:(NSError *)parseError {
}
- (void)parserDidEndParsingData:(mapParser *)parser
{
[self addAnnotation];
tabView.mapAnnotations2 = mapAnnotations;
self.mParser = nil;
[mParser release];
}
- (void)parser:(mapParser *)parser didParseItem:(NSArray *)parsedItem
{
NSLog(@"Did Parse Map Item");
[self.mapAnnotations addObjectsFromArray:parsedItem];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {}
@end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您的项目文件中很可能缺少这三个类。检查 XCode 项目中的 Classes 组以查看这三个文件是否存在。如果没有,则右键单击“类”组,然后单击“添加”>“类”。现有文件来添加它们。
如果将文件添加到项目中,请确保将这些缺少的类的实现 (.m) 文件添加到编译源中。要检查这一点,请展开组
Targets >您的申请目标>编译源
,并查看文件是否存在。如果没有,右键单击“Compile Sources”,然后转到Add >现有文件
添加它们。另一种可能更快的方法是为每个缺失的类选择 .m 文件,然后查看最右侧的靶心复选框是否已选中。如果没有,则检查它,它将自动添加到编译源中。Most likely these three classes are missing from your project file. Check the Classes group in your XCode project to see if these three files are present. If not, then right-click the Classes group, and click Add > Existing Files to add them.
If the files are added to the project, then make sure that the implementation (.m) files for these missing classes are added to compiled sources. To check that, expand the group
Targets > your application target > Compile Sources
, and see if the files are present. If not, right click on "Compile Sources", and gotoAdd > Existing Files
to add them. An alternative and maybe quicker way to do the same is by selecting the .m files for each of the missing classes, and see if the bulls eye checkbox on the far right is checked. If not, then check it and it will automatically get added to Compiled Sources.确保所有 (mapListViewController,mapParser,mapTabViewController) 都具有 @interface 和 @interface @implementation
这解决了我的问题。我碰巧错过了 @implementation 丢失的情况
Make sure all (mapListViewController,mapParser,mapTabViewController) have both @interface & @implementation
this solve my issue. i happen to miss look @implementation was missing
我遇到了同样的问题,我通过将框架添加到 xCode 中解决了这个问题
I was having the same issue which I resolved by adding the Framework into xCode
当你添加CoreGraphics库时,你需要选择project_name->targets/选择项目名称(不是选择项目测试名称,它是你面临的错误)->buildsetting->并添加CoreLocation.framework
when you add CoreGraphics libraray.you need to select project_name->targets/select project name (not select project test name,its an error you face)->buildsetting->and add CoreLocation.framework
当我尝试在应用程序扩展中使用
pod 'FirebaseRemoteConfig
时,我遇到了这个问题。我在扩展目标的构建设置中的其他链接器标志中添加了$(inherited)
而不是-ObjC
。我希望它对任何人都有帮助。我花了 1 个小时才找到这个解决方案。
I was having this problem when I was trying to have
pod 'FirebaseRemoteConfig
inside app extensions. I added$(inherited)
instead of-ObjC
to Other Linker Flags in the Build Settings of the Extension target.I hope it helps anyone out there. I have lost 1 hour finding this solution.