私が作成した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が表示されているときに1つのメニューが表示され、friendsMapViewが表示されているときに別のメニューが表示されます)。 – Brittany
あなたが提供した情報は十分ではありません、私は恐れています。リアビューコントローラとして設定しているビューコントローラを共有してください。デバッグをしましたか?問題に関するあなたの調査結果は何ですか? – Adeel