I have a iPhone app in which need to add UISearchbar on navigation bar, so that user can search from any where inside the app. When User Searches it displays search result in a Tableview controller and User can select any row which pushes to other controller.
Below is the Structure which i have in StoryBoard
- Navigation Controller
- Tab Bar Controller
- View Controller1
- View Controller2
- View Controller3
- View Controller4
- Tab Bar Controller
I can successfully add the UIsearchbar on Navigationbar in ViewController 1
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:SEARCH]];
imageView.frame = CGRectMake(0, 0, 20, 20);
UITapGestureRecognizer *tapGesture =
[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(searchTapped:)];
[imageView addGestureRecognizer:tapGesture];
self.searchButton = [[UIBarButtonItem alloc] initWithCustomView:imageView];
self.searchButton.style = UIBarButtonItemStylePlain;
self.searchButton.target = self;
[self.searchButton setTintColor:[UIColor whiteColor]];
self.tabBarController.navigationItem.rightBarButtonItem = self.searchButton;
I can successfully implement the Search results as well in Tableview controller but when user select row it Pushes to different controller. Below is the code which implmenetd to push to different controller.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
EntityViewController *entityController = [mainStoryboard instantiateViewControllerWithIdentifier:ENTITYIDENTIFIER];
entityController.dataDic = result;
[self.navigationController pushViewController:entityController animated:YES];
The problem here is when it pushes to different controller the TabBar is completely hidden and Navigation bar right button is completely Hidden.
I tried to Unhide the tab bar and Navigation bar but no effect. I tried all possibilities but nothing worked.
Can some one please let me know what is right approach to solve this issue.
Thanks In Advance.