I have a UISearchBar (& UISearchDisplayController) inside of a tableView side bar that I created (see photo attached). It is visible when a button in my UINavigationBar is tapped. Inside of my Map View Controller, I have a UISegmentControl in the navigation bar that allows my user to switch back and forth between views (mapView & friendsMapView).
For some reason, the UISearchBar appears just fine in the side bar when it is initially opened. However when I tap segment control to switch to friendsMapView, and then go back to mapView, my UISearchBar is gone (see photo).
Any idea why this could be? I've implemented the above in StoryBoard. See segmentControl code below (not sure if this helps):
.m
-(IBAction)segmentControl:(id)sender {
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UITableViewController *menuController;
menuController = [storyBoard instantiateViewControllerWithIdentifier:@"neighbourMenu"];
self.title = @"Controller 1";
switch (self.segmentControl.selectedSegmentIndex)
{
case 0:
[mapView setHidden:NO];
[friendsMapView setHidden:YES];
menuController = [storyBoard instantiateViewControllerWithIdentifier:@"neighbourMenu"];
break;
case 1: //FRIENDS MAP VIEW
menuController = [storyBoard instantiateViewControllerWithIdentifier:@"FriendMenu"];
// self.title = @"Item 1";
[mapView setHidden:YES];
[friendsMapView setHidden:NO];
//FRIENDS MAPVIEW LOCATION/ZOOM
friendsMapView.delegate = self;
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
#ifdef __IPHONE_8_0
if(IS_OS_8_OR_LATER) {
[self.locationManager requestWhenInUseAuthorization];
// [self.locationManager requestAlwaysAuthorization];
}
#endif
[self.locationManager startUpdatingLocation];
friendsMapView.showsUserLocation = YES;
[friendsMapView setMapType:MKMapTypeStandard];
[friendsMapView setZoomEnabled:YES];
[friendsMapView setScrollEnabled:YES];
break;
case 2:
[mapView setHidden:YES];
[friendsMapView setHidden:YES];
break;
}
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:menuController];
[self.revealViewController setRearViewController:nc];
}
I don't know your current viewcontroller but it seems you are setting a new navigationcontroller at below and your current viewcontroller's navigation bar has the search bar but the new navigationcontroller does not.
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:menuController];
[self.revealViewController setRearViewController:nc];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With