UIButton above UITableView - ios

I have a tableView in a UIViewController. My tableView is NOT an IBOutlet.
The UIViewController has a navigation bar due to being pushed from another view.
I want to add a UIButton above the tableview, but buttons/views do not appear above the tableview even if I add them in storyboard or use the "bringSubviewToFront" method.
I noticed that buttons/vews do appear behind the navigation bar when translucent, but that of course is not where I want them.
None of these codes have worked:
[self.view addSubview:btnSend];// add Send btn
[self.view bringSubviewToFront:btnSend];// bring Send btn to Front
[self.navigationController.view addSubview:btnSend];
[self.navigationController.view bringSubviewToFront:btnSend];
Thanks in advance.

you will need to set the edgesForExtendedLayout so that the top is not included
self.edgesForExtendedLayout = UIRectEdgeLeft | UIRectEdgeBottom | UIRectEdgeRight;

Related

add navigation bar to UITableViewController without using NavigationController

I am trying to add Navigation Bar to a UITableViewController without using NavigationController.
So in viewDidLoadMethod of MyUITableViewController, I create a Navigation Bar using CGRect.
UINavigationBar * navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 30, 320, 50)];
Then I present MyUITableViewController from MainViewController
[self presentViewController:controller animated:YES completion:Nil];
At this point my MyUITableViewController is overlapping with NavBar
I was thinking of creating tableViewController with initWithFram(x, y, width, height) to compensate for NavBar.
But I was not sure what height I should use and how to come up with a value. Would it have the correct scroll behavior??
What is the right way? Please note at this point I do not want to use Navigation Controller.
Is it possible w/o Navigation Controller.
Try not to use UITableViewController, but use simply UIViewController, add a UITableView object on it, and also implement the 2 protocols for table views.
You can resize the table view as you need, you can set its origin Y coordinate to 44 or 64 if you also need the status bar visible.
You can add a UINavigationBar object on top of it.
I hope doing this will help you solve the problem.

CollectionView content goes under NavigationBar

I added a UICollectionViewController using IB. Then I added a UINavigationBar in code:
UINavigationBar *navBar = [[UINavigationBar alloc] init];
[navBar setFrame:CGRectMake(0, 20, self.view.frame.size.width, 44)];
[navBar setDelegate:self];
[self.view addSubview:navBar];
All works fine except the fact that the collection view content is hidden by the navigation bar. It doesn't only scroll beneath the navigation bar but in fact displays beneath it when first loaded.
How can I fix that?
Why are you using a standalone navigation bar? It's probably a bad idea. Embed your view controller in a UINavigationController, and make sure the top contraint of your UICollectionView is set to the top layout guide and not the view.
try changing your content offset of the collection view. I'd try either 44 (height of nav bar) or 64 (height of nav bar + status bar)
Your problem is adding UINavigationBar on self.view which is UICollectionView.
You may use simple UIViewController with UICollectionView as subview of its view. Then after adding UINavigationBar you have to change collectionView.frame.

How to remove UINavigationBar label.text from second UIView Controller which is coming in first View controller?

I have one label which I am showing on UINavigationBar using addSubView Property and I am getting like:
But when I am going to secondView Controller, it is looking like:
It appears on Back Button of Second Controller. So how to remove "Status" Label from second UI.
Thank You.
Don't add subviews to the navigation bar. It's not made for that.
I recommend you to read the iOS human interface guidelines and to use a UIBarButtonItem to properly add controls to the navigation bar.
In first View controller -
-(void)viewWillAppear:(BOOL)animated
{
//Add Label on UINavigationBar
[super viewWillAppear:animated];
[self.navigationController.navigationBar addSubview:navLabel];
}
-(void)viewWillDisappear:(BOOL)animated
{
// Remove label from UINavigationBar
[super viewWillDisappear:animated];
[navLabel removeFromSuperview];
}
You should tag your subview and search for it among subviews of navigation bar in your second view controller and then [subview removeFromSuperview].
You shouldn't add subviews to your navigation bar, you can use navigation items to achieve that kind of stuff. You can init a UIBarButtonItem with initWithCustomView: which has that label in it.

UITabBarController and custom control acting as a tabbar

I have a custom tab bar controller subclass and instead of a tab bar, I use a custom UIView.
The problem is that I cannot get my view controllers to appear. I see a white screen and the "tab" if I call
[super setViewControllers:]
I get really odd artefacts as far as appearance goes.
So instead I tried setting the selectedViewController directly. I've kind of drawn a blank. Any help would be greatly appreciated.
Can you tell me how you are having a custom view for tabs..
Have u removed tabBar & added ur custom tabView.? and keep in mind if remove your tabBar the whole tabBarController will be removed..
So you need to just hide the tabBar from tabBarController and add ur custom UIView in place of tabBar and everything works fine. You have to select the tab index programatically as per the button selection in your custom view.
You can use view Controller containment concept in order to implement custom tabbar.
[self addChildViewController:content]; // 1
content.view.frame = [self frameForContentController]; // 2
[self.view addSubview:self.currentClientView];
[content didMoveToParentViewController:self]; // 3
You can also use my custom control
Custom Tabbar Control

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