Sự cố khá dễ hiểu với hình ảnh. Tôi có một UINavigationController cho phép người dùng chuyển đổi giữa các chế độ xem.NavigationBar không hiển thị thích hợp khi pushViewController
Quan điểm thứ nhất chứa một thanh tìm kiếm và một cái nhìn bảng như sau:
Việc thứ hai là một cái nhìn cơ bản trong đó thông tin về các tế bào đang hiển thị
Khi tôi bấm vào thanh tìm kiếm, điều hướng bộ điều khiển bị ẩn và thanh tìm kiếm hiện ở trên cùng.
Bây giờ, nếu tôi bấm vào một ô, nó đi với quan điểm thứ hai, nhưng thanh điều hướng là lần đầu tiên ẩn như dưới đây:
Và sau đó, nó tự động xuất hiện như thế:
tôi đã thử một vài thứ như hiển thị thanh điều hướng trước khi đẩy bộ điều khiển xem tiếp theo nhưng nó là khá xấu xí .. có ai biết làm thế nào để có hiển thị thanh điều hướng trực tiếp trên chế độ xem thứ hai (như trong ứng dụng liên hệ) không?
[UPDATE]: Mã
AppDelegate.m (Tôi đang nói về navigationcontroller2)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
FirstViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
SecondViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
viewController1.managedObjectContext = [self managedObjectContext];
viewController2.managedObjectContext = [self managedObjectContext];
viewController1.viewController2 = viewController2;
UINavigationController *navigationcontroller1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
[navigationcontroller1.navigationBar setTintColor:[UIColor lightGrayColor]];
UINavigationController *navigationcontroller2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
[navigationcontroller2.navigationBar setTintColor:[UIColor lightGrayColor]];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationcontroller1, navigationcontroller2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
FirstView.m
- (void) searchBarTextDidBeginEditing:(UISearchBar *)theSearchBar {
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!noResultsToDisplay) {
PinDetailsViewController *pinDetailsViewController = [[PinDetailsViewController alloc] initWithNibName:@"PinDetailsViewController" bundle:nil];
NSManagedObject *managedObject = [fetchedResultsController objectAtIndexPath:indexPath];
Pin *pin = (Pin *) managedObject;
[self.navigationItem setTitle:@"Pins"];
[self.navigationController pushViewController:pinDetailsViewController animated:YES];
[pinDetailsViewController updateWithPin:pin];
}
}
Nếu bạn cần bất cứ điều gì khác, chỉ cần hỏi nhưng tôi nghĩ rằng đó là tất cả ở đó.
Vui lòng đăng một số mã. Nếu không thì rất khó để xem vấn đề ở đâu. – MishieMoo