ios - Custom Delegate with Modal Form Sheet not working -


i have gone through of previous related posts, although have followed them correctly (as far understood), not able trigger delegate method below code.

objective: modalview generates string *sql_string. press done dismiss modalview , trigger delegate method in parentview *sql_string.

searchmodalviewcontroller.h

@protocol searchcontrollerdelegate - (void)diddismissmodalview:(nsstring *)sql_string; @end  @interface searchmodalviewcontroller : uiviewcontroller @property (nonatomic, assign) id <searchcontrollerdelegate> searchdelegate; - (ibaction)handledone:(id)sender; 

searchmodalviewcontroller.m

@interface searchmodalviewcontroller () @end  @implementation searchmodalviewcontroller @synthesize searchdelegate;  - (ibaction)handledone:(id)sender {     [self dismissview:sender]; }  - (void)dismissview:(id)sender {     [searchdelegate diddismissmodalview:@"test"];     [self dismissviewcontrolleranimated:yes completion:nil]; } 

detailviewcontroller.m (my parent view controller)

@interface detailviewcontroller () <searchcontrollerdelegate> - (void)viewdidload {     [super viewdidload];     // additional setup after loading view, typically nib.      searchmodalviewcontroller *searchmodal = [[searchmodalviewcontroller alloc] init];     searchmodal.searchdelegate = self; } 

problem:

below delegate method not getting triggered.

- (void)diddismissmodalview:(nsstring *)sql_string {     [self dismissviewcontrolleranimated:yes completion:nil];     nslog(@"the string = %@", sql_string); } 

any idea doing wrong?

edit: thank guys. fast suggestions, able close down adding below code instead of previous ib connection.

- (ibaction)showsearchmodal:(id)sender {     searchmodalviewcontroller *searchmodal = [self.storyboard instantiateviewcontrollerwithidentifier:@"search"];     searchmodal.searchdelegate = self;     searchmodal.modalpresentationstyle = uimodalpresentationformsheet;     searchmodal.modaltransitionstyle = uimodaltransitionstylecrossdissolve;     [self presentviewcontroller:searchmodal animated:yes completion:nil]; } 

here goes

change detailviewcontroller.m

- (ibaction)pushtosearch:(id)sender{     searchmodalviewcontroller *searchmodal = [self.storyboard instantiateviewcontrollerwithidentifier:@"search"];     searchmodal.searchdelegate = self;     [self presentviewcontroller:searchmodal animated:yes completion:nil]; } 

and work.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -