iOS:How to add a view on searchBar in UISearchDisplayController and I want the view on top of _UISearchDisplayControllerDimmingView - ios

How to add a view on searchBar in UISearchDisplayController and I want the view on top of _UISearchDisplayControllerDimmingView?
I add the view by [self.searchDisplayController.searchBar insertSubview:view3 atIndex:0];. But it was under _UISearchDisplayControllerDimmingView.
I show U the pic:
If someway to dismiss the _UISearchDisplayControllerDimmingView will help me also!

If you really want it on the top of dimView put your view on the window of Application.
UIView *view = [[[UIApplication sharedApplication]windows]objectAtIndex:0];
and add your view as subview.

Related

InputAccessoryView covers the bottom bar

Any idea how to get an inputAccessoryView to anchor to the tab bar rather than the bottom of the screen?
I have created a UIViewController and overridden the following methods:
-(BOOL)canBecomeFirstResponder {
return YES;
}
-(UIView *)inputAccessoryView {
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, 44);
self.keyboardInputAccessoryView =[[BRKeyboardInputBarView alloc] initWithFrame:frame leftButtonTitle:#"Left" andRightButtonTitle:#"Send"];
[self.keyboardInputAccessoryView setDelegate:self];
[self.keyboardInputAccessoryView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.keyboardInputAccessoryView removeFromSuperview];
return self.keyboardInputAccessoryView;
}
View controller with inputAccessoryView covering the tab bar
By the looks of it the view controller adds the view to the window rather than the current view controllers view, which would explain its positioning. However if I remove the line:
[self.keyboardInputAccessoryView removeFromSuperview];
I get a crash when I tap in the textview of my accessory view:
The view hierarchy is not prepared for the constraint:<NSLayoutConstraint:0x7fa0c2ca5f80 BRKeyboardInputBarView:0x7fa0c2d6fad0.bottom == UIInputSetContainerView:0x7fa0c295a2c0.bottom>
So I guess what I am asking is what is the correct way to add a keyboard accessory view so that it plays nicely with auto layout and avoids the crash, but also anchors itself to the view and not the window?
What you are seeing is the right behaviour.
The results you are seeing is because of the fact that UIViewController is a UIResponder subclass. By overriding the inputAccessoryView and returning an instance of a view, UIViewController will take care of placing that view at the bottom of the screen and animating it appropriately when keyboard appears or disappears.
If you want to add this bar on top of your keyboard, then you need to set the property inputAccessoryView of a textField/textView to your custom view.

iOS - Adding view under navigation bar

I can't add a view under UINavigationBar (Navigation Controller), like the Facebook app. Any ideas on how I can do this?
Best,
Andrea
The custom view looks like a tableHeaderView. Which means you need to set your view as the tableHeaderView, which will then be placed on top of the tableView and underneath your navigation bar.
UIView *customView = [[UIView alloc] initWithFrame:yourFrame];
self.tableView.tableHeaderView = customView;

Pinned subview of a popover controller having a tableview inside

I am trying to add a hovering subview to a UIPopoverController. I have a table view controller as a content view controller inside the popover. I tried to add it as a normal subview:
UIPopoverController* popoverController = [[UIPopoverController alloc] initWithContentViewController:myTableViewController];
UIView* mySubview = ...
[popoverController.contentViewController.view addSubview:mySubView];
It is displayed correctly but unfortunately scrolls up and down with the table view. I would like to have its position fixed.
I also tried to update the position of the subview by the y offset of the scrollview in the scrollViewDidScroll: method of the table view controller, but would like to avoid this solution if possible.
You have to make the content controller a UIViewController subclass rather than a UITableViewController subclass.

Navigation controller with two views

I have a navigation controller that controls view switch. How can I show a view without removing the current view?
if your new view has a view controller use
[self.navigationController presentModalViewController:newController animated:YES];
This will add a view to the viewcontrollers view.
[parentView addSubview:subView];
This will add the view in variable subView into the view in variable parentView. In your case this would mean parentView is the viewcontroller's view and the subView is the view you want to add.
You can change the position of the subView in the parentView by setting the subview's subview.frame property.
If you are talking about a viewController you want to show take a look at the answer of Andiih.

How to add navigation bar in uitableview

App based on Navigation base application.How to add Navigation bar in UItableview controller. Symptoms as a tableview controller(xib). I need to add in Navigation bar to symptoms.
you dont add a navigationController to a tableViewController. its the other way around.
First add anavigationController and set its rootViewController as the tableViewControler.
U can add it as you add the sub view to super view
-loadview:
navBar2=[[UINavigationBar alloc]init];
[navBar2 sizeToFit];
[self.view addSubview:navBar2];
//add button on the bar.
[navBar2 addSubview:button];
maybe u can change in the xib, add a UIView below the TableView and then add the navigation bar as a subview of UIView

Resources