userLocationVisble returns error
I have a mapview where i update my currentlocation with CoreLocation, but I also have checks which uses userLocation.
I still haven't found an alternative in fixing my problem But for some reason I can't use userLocationVisible to hide the blue dot.
When I enter my MapView I start the locationManager, but before I have updated my location, the blue dot appears and my pin doesn't show up.
I've tried to use a custom MKAnnotation and init the coordinates with the newLocation from DidUpdateToLocation. But when I run this I get:
-[Cu开发者_C百科stomPlacemark setCoordinate:]: unrecognized selector sent to instance 0x1de6c0
this is my CustomPlacemark:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface CustomPlacemark : NSObject<MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subtitle;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *subtitle;
-(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;
- (NSString *)subtitle;
- (NSString *)title;
@end
#import "CustomPlacemark.h"
@implementation CustomPlacemark
@synthesize coordinate;
@synthesize title, subtitle;
-(id)initWithCoordinate:(CLLocationCoordinate2D) c{
self=[super init];
if (self!=nil) {
coordinate=c;
}
return self;
}
-(NSString*)title{
return title;
}
-(NSString*)subtitle{
return subtitle;
}
-(void) dealloc
{
[title release]; title = nil;
[subtitle release]; subtitle = nil;
[super dealloc];
}
@end
Can someone also tell me why I can't use UserLocationVisible??
cordinate is read only property for customplacemark class . so u can not set cordinate property. to set cordinate property make it read and write.
change line@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
To @property (nonatomic, readwrite) CLLocationCoordinate2D coordinate;
The right way to do it will be initWithCoordinate rather than making the property readwrite
The blue dot appears when you set showsUserLocation=YES; If you want to hide the blue dot, set this to NO. Alternatively, you can determine if the user's location is visible on the screen using CoreLocation and enable showsUserLocation to YES.
Also, the blue dot is a special annotation class MKUserLocation that conforms to MKAnnotation protocol. If you are sending any messages to annotation objects that are your own class, you may want to exclude MKUserLocation annotation object.
If you want to know how to specifically deal with your custom annotation objects without sending incorrect messages to MKUserLocation class, let me know, I have the code that I can send.
精彩评论