6
votes

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).

enter image description here

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).

enter image description here

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];



}
1
you probably just want to show/hide mapView and friendsMapView based on the selection of segmentedControl options. I'm not sure why are you changing the rearViewController of the revealViewController every time user selects an option form segmentedControl?Adeel Miraj
@Adeel Because a different menu is visible in the side bar when friendsMapView is displayed (one menu visible when mapView displayed, different menu visible when friendsMapView is displayed).Brittany
The information that you've provided is not enough I'm afraid. Please share the view controllers that you are setting as rear view controllers. Have you done any debugging? Please share what's your findings about the issue.Adeel Miraj

1 Answers

2
votes

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];