uisearchbar - bar button created from childViewController don't work -
i have parentviewcontoller(with uinavigationitem), , childviewcontoller(with uitableviewcontoller, uisearchbar). want create uibarbuttonitem on click searchbar hiding.
tableviewcontoller.h(childviewcontoller) @interface tableviewcontroller : uitableviewcontroller<uisearchbardelegate, uisearchdisplaydelegate, uinavigationcontrollerdelegate> @property (nonatomic, strong) iboutlet uisearchbar *searchbar; @end tableviewcontoller.m(childviewcontoller) @synthesize searchbar; - (void)viewdidload { [super viewdidload]; self.searchbar.hidden = no; [self createsearchbutton]; } - (void) createsearchbutton { uibarbuttonitem *mybutton = [[uibarbuttonitem alloc] initwithtitle:@"mybutton" style:uibarbuttonitemstylebordered target:self action:@selector(ibutton:)]; self.parentviewcontroller.navigationitem.rightbarbuttonitem = mybutton; } -(void) ibutton { self.searchbar.hidden = yes; nslog(@"click on ibutton"); }
but, if click on mybutton, nslog displayed, , searchbar not hidden. why code don't work?
Comments
Post a Comment