我在創建的tableView側欄內有一個UISearchBar(& UISearchDisplayController)(請參閱附圖)。當我的UINavigationBar中的按鈕被點擊時它是可見的。在我的Map View Controller內部,我在導航欄中有一個UISegmentControl,它允許我的用戶在視圖之間來回切換(mapView & friendsMapView)。當使用UISegmentControl切換視圖時,UISearchBar消失
出於某種原因,在的UISearchBar側欄時,它最初打開出現就好了。但是,當我點擊段控制切換到friendsMapView,然後回到mapView,我的UISearchBar消失了(見圖)。
任何想法,這可能是爲什麼?我已經在StoryBoard中實現了上述功能。請參見下面segmentControl代碼(不知道這是否有助於):
.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];
}
您可能只想根據選擇的segmentedControl選項來顯示/隱藏'mapView'和'friendsMapView'。我不知道爲什麼每次用戶選擇'segmentedControl'選項時都要更改'revealViewController'的'rearViewController'? – Adeel
@Adeel因爲當顯示friendsMapView時,在側邊欄中可以看到不同的菜單(當顯示mapView時顯示一個菜單,當顯示friendsMapView時顯示不同的菜單)。 – Brittany
您提供的信息恐怕不夠。請分享您設置爲後視控制器的視圖控制器。你有沒有做過任何調試?請分享你對這個問題的發現。 – Adeel