ios - Can't send a UIButton event to other view controller correctly -


can provide examples , formal patterns one-to-one event transfer between uiviewcontrollers? think nsnotificationcenter not applicable use case because based on event bus , broadcasting patterns broad state changes , that's why should used one-to-many transfers. know kvo not applicable in case at all too, because used communication between model , controller layers in classical mvc realm. know 1 way one-to-one event transfers: delegate pattern. may there more elegant , simple not easy solutions.

for example:

in view action sent to:

@protocol mapviewdelegate <nsobject>  @required  -(void)mapimagebuttonclicked:(uibutton*)sender;  @end  @interface mapview : uiview {     uibutton    *mapbutton;     id          mapviewdelegate; }  @property(nonatomic,retain)     id              mapviewdelegate; @property(nonatomic,retain)     uibutton        *mapbutton; 

.m

  [mapbutton addtarget:self.delegate action:@selector(mapimagebuttonclicked:) forcontrolevents:uicontroleventtouchupinside]; 

in view action sent from:

#import "mapview.h"  @interface mapviewcontroller : uiviewcontroller<mapviewdelegate> {  }  .m  mapview *map = [[mapview alloc] init]; map.delegate = self;  -(void)mapimagebuttonclicked:(uibutton*)sender {  //implement necessary functionality here } 

hope idea. please implement according situation.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -