ios - How to add image views to custom annotation view keep pin image on screen and take touches from it? -



ios - How to add image views to custom annotation view keep pin image on screen and take touches from it? -

i have mapview pins show location of photo (coordinates taken coredata) , need show photo when pin selected (using url , afnetworking).

i need save both pin image and photo image when pin selected.

if next pin selected previous pin deselected remove photo screen , add together photo of corresponding pin.

here image show particularly need:

so pin on screen , photo on screen.

problems:

this task iphone usage of popover not available. i need maintain both image of pin , photo, not image instead of pin. that's why cannot utilize property 'image' of mkpinannotationview class - sets image instead of pin. mk has private classes views using search on touches problem.

solution first , sec problem: i've made custom class of mkpinannotationview responsible adding imageview mkpinannotationview maintain both pin image , photo on screen.

#import "psmkpinannotationview.h" //my custom annotations, maintain urls , coordinates of photos there. #import "psmapannonation.h" #import "uiimageview+afnetworking.h" //to display images url @interface psmkpinannotationview () @property (nonatomic, strong) uiimageview *imageviewforannotaion; //property in header is: //@property (nonatomic, getter = isdetailviewhidden) bool detailviewhidden; @end @implementation psmkpinannotationview - (bool)validannotation { homecoming [self.annotation iskindofclass:[psmapannonation class]]; } - (void)setdetailviewhidden:(bool)detailviewhidden { //draw image in custom view if (detailviewhidden==no) { if ([self validannotation]) { self.annotation=(psmapannonation*)self.annotation; cgrect rect=cgrectmake(0, -35, 30, 30); // y=-35 create right offset self.imageviewforannotaion = [[uiimageview alloc] initwithframe:rect]; [self.imageviewforannotaion setimagewithurl: [(psmapannonation*)self.annotation imageurl]]; [self setclipstobounds:no]; [self addsubview:self.imageviewforannotaion]; } } else if (detailviewhidden==yes) { if ([self validannotation]) { [self.imageviewforannotaion removefromsuperview]]; } } }

in viewcontroller mapview in methods of mapview i'm doing this:

- (void)mapview:(mkmapview *)mapview didselectannotationview:(psmkpinannotationview *)view { if ([view.annotation iskindofclass:[mkuserlocation class ]]) return; view.detailviewhidden=no; } -(void)mapview:(mkmapview *)mapview diddeselectannotationview:(mkannotationview *)view { if (![view iskindofclass:[psmkpinannotationview class]]) { return; //blue point describes currecnt user position view pin //and in case of beingness selected without check app crash. } psmkpinannotationview *customannotationview=(psmkpinannotationview*)view; [customannotationview setdetailviewhidden:yes]; }

so, i've made solution first 2 problems:

the result this:

but 3rd problem detected during search on touched views om mkmapview

#pragma mark - touches - (void) touchesbegan:(nsset *)touches withevent:(uievent *)event { nslog(@"touch"); uitouch *touch = [[event alltouches] anyobject]; cgpoint touchlocation = [touch locationinview:self.mapview]; (uiview *view in self.mapview.subviews) { if ([view iskindofclass:[psmkpinannotationview class]] && cgrectcontainspoint(view.frame, touchlocation)) { nslog(@"%@",[view class]); } nslog(@"%@",[view class]); } }

logs show me apple's private classes:

- 2014-06-19 11:00:45.428 photoshare[881:60b] touch - 2014-06-19 11:00:45.428 photoshare[881:60b] uiview - 2014-06-19 11:00:45.428 photoshare[881:60b] mkattributionlabel - 2014-06-19 11:01:47.574 photoshare[881:60b] touch - 2014-06-19 11:01:47.575 photoshare[881:60b] uiview - 2014-06-19 11:01:47.575 photoshare[881:60b] mkattributionlabel

in case of touch on photo (its image view) custom class view not detected , mkattributionlabel , uiview shown

is there simple solution stuff?

how connect touches added imageview , find them in views? logs showed me mapkit adds own views mkattributionlabel(apple's private classes)?

ios mapkit mkannotation mkannotationview mkpinannotationview

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -