ios - Can't push a view onto searchResultsController -
i have tableviewcontroller, searchresultscontroller , webviewcontroller. when click on cell in tableviewcontroller pushes webviewcontroller opening url related cell.
the tableviewcontroller has uisearchcontroller filters results searchresultscontroller when cell clicked in searchresultscontroller webviewcontroller doesn't pushed.
here code didselectrowatindexpath searchresultscontroller:
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { webviewcontroller *webviewcontroller = [[webviewcontroller alloc] init]; nsstring *extensionurl = (self.searchresults[indexpath.row])[@"url"]; nsurl *baseurl = [nsurl urlwithstring:@"http://www.baseurl.com"]; nsurl *url = [nsurl urlwithstring:extensionurl relativetourl:baseurl]; webviewcontroller.title = (self.searchresults[indexpath.row])[@"title"]; nslog(@"%@", url); webviewcontroller.url = url; [self.navigationcontroller pushviewcontroller:webviewcontroller animated:yes]; }
i included nslog see if happened when cell clicked , display url in console. makes me think problem navigationcontroller.
looking online seems uisearchcontroller should wrapped in uisearchcontainerviewcontroller should put in navigationcontroller. i'm still new app development , can't figure out how or this.
i call searchresultscontroller in viewdidload of tableviewcontroller so:
- (void)viewdidload { [super viewdidload]; searchresultsviewcontroller *controller = [[searchresultsviewcontroller alloc] initwithstyle:uitableviewstyleplain]; [self addobserver:controller forkeypath:@"results" options:nskeyvalueobservingoptionnew context:nil]; self.searchcontroller = [[uisearchcontroller alloc] initwithsearchresultscontroller: controller]; self.searchcontroller.searchresultsupdater = self; self.searchcontroller.hidesnavigationbarduringpresentation = no; self.searchcontroller.dimsbackgroundduringpresentation = no; self.searchcontroller.delegate = self; self.definespresentationcontext = yes; uisearchbar *searchbar = [[uisearchbar alloc] init]; searchbar = self.searchcontroller.searchbar; searchbar.searchbarstyle = uisearchbarstyleminimal; uitextfield *searchfield = [searchbar valueforkey:@"_searchfield"]; searchbar.bartintcolor = [uicolor whitecolor]; searchbar.tintcolor = [uicolor whitecolor]; self.navigationitem.titleview = searchbar; }
is should embedding searchresultscontroller?
when doing search present newmodalviewcontroller simple need steps pushing viewcontroller when present search controller
1)self.definespresentationcontext = yes;
after should push viewcontroller
2) [self.presentingviewcontroller.navigationcontroller pushviewcontroller:sec animated:yes];
note:present modalviewcontroller doesnt have navigation controller normal push coding wont work not allocated navigation.
enjoy.....
Comments
Post a Comment