UISearchController's searchbar is not responding - ios

I am not able to get responding events on tapping UISearchController's search bar in iOS 8.
I am displaying custom view with dim background like alert view appearance, on pressing button in a view, where custom view has UISearchController's search bar as sub view. Programmatically added searchController. When I try to touch search bar, it is not responding in iOS 8 whereas I have added search bar with UISearchDisplayController for iOS 7, it is working fine.
I have viewController A with navigation bar. In viewController A, I have a button. On pressing button, I am trying to show view as custom view with dim background like alert view appearance. So I have added following line in button method.
class_name *view = [[class_name alloc] initWithNibName:#"xib_name" bundle:nil];
[self.navigationController.view addSubview:view];
Xib file of class_name has dim background with subviews like searchController's search bar.
Instead of
[self.navigationController.view addSubview:view];
added
[self presentViewController:view animated:YES completion:nil];
UISearchController's search bar is working now but i am not able to get transparent background view, instead black background appears.
I need to display previous views content and on top that current views content like alert view.
Please guide me in objective-C.

Related

xcode how can i remove the top bar from a subview

i have a sub view in the main view but for some reason the sub view keep show that bar under the carrier text when Im in the in the subview screen i do not see this bar only when Im in the the main view or previewing the app on the simulator
if you want hide statusBar
[UIApplication sharedApplication].statusBarHidden = YES;
if you want hide navigationBar
[self.navigationController setNavigationBarHidden:YES];

How to remove navigation subview when view disapper?

I am using custom navigation view for navigation bar.
CustomNavigation *navigation = [[CustomNavigation alloc] initWithNibName:#"CustomNavigation" bundle:nil];
[self.navigationController.navigationBar addSubview:navigation.view];
This is my code for custom navigation to addsubview for navigation. I am using in viewwillapper. Because it's show and hide image and button based from popviewcontroller.
Here my problem is I need to dealloc this customnavigation view but I am already tried in view disappear it won't work? :( (I am using find that issue by "debug view hierarchy" in Hide or show debug area )
Am I using correct way for custom navigation bar or else give me correct way to create customized navigation bar?
If this is correct way to create customized navigation bar then how to dealloc this custom navigation view when view disapper?
I am new bee for xcode so give some little more explanation maybe I am struggles to understand. :(
Sample APP navigation only one at home screen also pop from another view
Sample APP at second view
My app at home screen
After few view my home screen navigation
Check all screens you will understand what I want.
I want to dealloc all navigation bar allocation form manually.
Screen shot's from "debug view hierarchy" in Hide or show debug area - XCODE.
This is worked for me :)
Add a tag for that view each time when I use add subview code before
for(UIView *view in [self.navigationController.navigationBar subviews])
{
if(view.tag == 1000 && [view isKindOfClass:[UIView class]])
{
navigation = nil;
[view removeFromSuperview];
}
}
If it's not perfect answer then show the correct one. Advance thanks.

alternating between toolbar / tab bar

my app is structured as follow: UITabBarController > UINavigationController > ViewControllerOne > ViewControllerTwo.
the UINavigationBar has at the bottom the tab bar, now when the user navigates into the second view controller, i want to be able to hide the tab bar and replace is with a tool bar. i tried this code:
[self.navigationController.tabBarController.tabBar setHidden:YES];
[self.navigationController.toolbar setHidden:NO];
when i run the app the tab bar is hidden but the toolbar doesn't appear. plus, since the last VC is a table view controller, when i scroll through the cells there is a white gap between the table and the bottom of the view. how can i fix that?
That won't work because when you hide the tab bar like that the subviews won't be adjusted properly (that's why you get the white space). You'll have to use
self.hidesBottomBarWhenPushed = YES;
In your init method or awakeFromNib... and then
[self.navigationController setToolbarHidden:NO animated:YES];
In the viewDidLoad for example.
That way the tab bar controller's view is going to layout correctly it's subviews when you hide the tab bar. Just remember to call self.hidesBottomBarWhenPushed = NO; in your first view controller otherwise the tab bar is still going to be hidden when the second view controller is popped from the navigation stack.
Try to assigning toolbar with appropriate frame and adding it to self.tabBarController.view

How can I show a back arrow in the master-view popover button for UISplitViewController in iOS 7?

In my detail VC, I am implementing this UISplitViewController delegate method:
- (void)splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)pc
It is then easy for me to set the title of the button, but the result is just a button with plain text, and no back arrow. I am looking to get something like the Mail app where the master popover button also has the back chevron.
How can I do this?
Create your custom bar button item, with the chevron image, set up as you want, and set the target and action of your bar button item to be that of the one passed by the delegate callback. This way, your bar button will perform the same action as the one the system passes to you. You must create your own bar button with an image, because there is no possible way with AppStore approved API to create back bar buttons.
In iOS7, the private subclasses are UINavigationItemView + _UINavigationBarBackIndicatorView. One is the button, the other - the chevron. _UINavigationBarBackIndicatorView is a subclass of UIImageView. So it's pretty close to what you will achieve.
In iOS 8, UISplitViewController has a method:
- (UIBarButtonItem *)displayModeButtonItem
If you set the returned bar button item as the left button of a navigation bar (UINavigationBar), it will display the chevron for you.
On the other hand, if you put the returned bar button item into a toolbar (UIToolbar), it will not display the chevron.
For places where I want the chevron back button shown, but also need several of my own bar button items shown (like the Mail app on iPad does), I have to use a UINavigationBar and a UIToolbar. It's an ugly solution, but I have to partially overlay the UINavigationBar on top of the UIToolbar in order to get a back button chevron along with several of my own bar button items.
To access the default back button image used by Apple as what Leo said, the arrow is a class of type _UINavigationBarBackIndicatorView. Set this image to a back bar button and you are good to go.
Here follows the hack,
UIImage *imgViewBack ;
for (UIView *view in self.navigationController.navigationBar.subviews) {
// The arrow is a class of type _UINavigationBarBackIndicatorView. This is not any of the private methods, so I think
// this is fine for the AppStore...
if ([NSStringFromClass([view class]) isEqualToString:#"_UINavigationBarBackIndicatorView"]) {
// Set the image from the Default BackBtn Imageview
UIImageView *imgView = (UIImageView *) view;
if(imgView){
imgViewBack = imgView.image ;
}
}
}
This is based on Ryan Henning's answer.
It's possible to show a back button representing the master view from the detail view controller. The UISplitview controller doesn't provide a native method for this, but it returns a bar button object which we can directly assign as navigation controller bar button. Its obvious that the detail view controller should be inside a navigation controller for this to work.
self.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;

NavigationBar coincides with status bar when searchDisplayController is activated iOS 7

I have a tableView controller which has a searchbar added to tableHeaderView. When I click on searchBar it animates to cover the screen. However, the view behind gets adjusted and navigationBar overlaps with status bar as shown below:
It adjusts back fine, when the search is cancelled. How to hold the view at the back of searchDisplayController not to overlap the status bar?
fixed by doing: [[[parentFileViewController navigationController] navigationBar] setHidden: YES]; in searchDisplayControllerWillBeginSearch method where parentFileViewController contains the searchBar

Resources