how should i add a textfield/button to a table view controller? - swift

I have a UITableViewController with a nav bar up top from an embedded nav controller. In between the nav bar and the start of the cells I'm trying to add a textfield and button sort of like a search bar layout but for a different purpose.
On my storyboard, I can drag in a button or a label, but it automatically fills the width of the scene. As a result there is only room for one or the other. I tried editing with the size inspector in the right pane but it reverts to the old number everytime.
How would I pull this layout off?

Create a view with the label/text field and the button then drag the view to the top of the tableview. It will add the view as a header view.

Related

issue in StoryBoard: Other views at the top of the table view are not visable

I have started an app using story board.
In that i have used tabbar controller
In a view, I have Table view in that having a custom cell, And I have added a search bar at the top of the Table view. as shown bellow
The problem is when I add Search bar very close to the navigation bar, It does not display and if i added little down it was displayed
what was the issue is in 2px difference?
Go to IB Inspector
Select search bar and set AutoSizing Mask like this attached Picture.. Enable left, right, top and center position.

Add Tabs To MasterView Controller Project

I created a MasterViewController project with a tableView, now I'd like to add some tabs to this. I tried to just drag and drop the tab bar into the MasterViewController and the tabs show, but they are linked the the last cell in the tableView.
Is there any way to make the tabs stay in place so they are always displayed? What I am trying to accomplish is to give the user buttons to push to organize the data in the tableView, so I'm open to other suggestions.
Here are the pictures:
You need to have your controller be a UIViewController, not a UITableViewController (where the table view is the controller's self.view, and is full screen). If you use a UIViewController, you can add a table view, and size it such that you have room at the bottom to add the tab bar. In that case, both the table view and the tab bar are subviews of the controller's self.view. The way you're trying it, the tab bar is added to the table's scroll view.
It sounds like you added it as a subview of the table view, so as the table view scrolls it scrolls too. Look at creating a container view to hold both the tableView and tab bar / segmented control / buttons positioned below it. You will need to make the controller a subclass of UIViewController instead of UITableViewController.
Alternatively, use the navigation bar to add some edit button(s), either to enter an editing mode which shows controls on each row or where the buttons actually edit the currently selected row.
Tab bars are container controllers and are used to present a different mode of your application. If you want to only organize your tableview data, my suggestion is to use UISegmentedControl.

Displaying a ToolBar above the Tabbar

I have a scroll View. Now i need to add a tool bar when a button is clicked (above the tab bar). Since this is a scroll View, even if the user scrolls the page down the tool bar should be visible right above the toolbar.
my solution so far;
1.) i added the toolbar to a Window, and display the window (But i don't want to use a Window). Is there a way to do this using a UIView ?
My pseudocode : ToolBar ---(added to)--> UIWindow ----(display)--->
display
Create a containing view to house both your scroll view and the toolbar. Initially have your scroll view the full size within the containing view. Resize it smaller on button press and add the toolbar below it. When you hide the toolbar do the reverse (remove the toolbar from the containing view and resize the scroll view back to taking up the full view).

How to prevent subview from overlapping tab bar?

I have a view with tab bar at the bottom. This view is pushed on a navigation controller, so there is also a navigation bar at the top. Unto this view, I would like to show a table view, which I create from its own nib. When I add this view as a subview, it overlaps the tab bar.
Is there a way to make this subview automatically resize to the free space in between the top and bottom bar?
If not, what is the 'right' way of adjusting its size to fit?
-Vegar
In the interface builder make sure that you've set the navigation bar and tab bar spacers up. It should be the first list of options on the first tab in the Interface builder Properties view. This will make your view mimic the amount of space it has when loaded in the view.
From there you can also choose the option to clip the subview. The interface builder also allows you to set resize options for the view. If the subview your adding wasn't created in the interface builder you'll have to specify those options manually.
Lastly make sure that your appending the subview to the correct view, and not the tab bar controller or navigation controller.
Best bet is to make sure the subview your addings dimensions are appropriate for the amount of space you have by creating a frame using CGRect.

Overlaying views & positioning

I have a tab bar view, and another UIView which contains a button, which needs to be visible just above the tab bar.
I have added another view which always sits above the current select tab's view, but can't figure out how to make it sit just above the tab bar Screenshot http://img.skitch.com/20090524-jq6ufyiwp6c2uu1x5tkrrsd97m.jpg
I would suggest sub-classing the tabbar to include the new view. That way you do not have to worry about a tab overlaying the view. All your resizing should be done automatically and you will never accidentally hide a component.
You can also have the controller also look after the button and view that you add. you would just need to replace the tabbar in the tabbarviewcontroller to be your one.
Add your view with button in the tab bar view and use either one of these
– bringSubviewToFront:
– insertSubview:aboveSubview:
to put it above all and check how many pixels you need to position your button so that it does not get above the tabs.
You could also add it at the window level.