Space in the content of UITableView - ios

Today I faced a weir bug in UITableView.
I have a UIViewController containing a UITableView. I also have a root viewcontroller, which will add the aforementioned UIViewController as a child.
Now when loaded, it shows a space between cells and the top border.
How can I fix that?

Try to deselect Adjust Scroll view insets option of the ComicsVC view controller.
First select ComicsVC item in the left window of your storyboard, then in the attributes inspector you will easily find this checkbox.

You have to set top position of UITableView to 0. Also you have to add constraints between UITableView and parent UIView.
This bug appears when you use translucent navigation bar.

That space shows up for grouped UITableViews, and is usually occupied by a section header. If you don't implement a section header, then the area will be blank.
If you don't have more than one section, go to the UITableView in the storyboard, show the properties, and change the style to Plain.
Hope this helps!

Related

How to add buttons and search bar into header at top of UITableViewController?

I have a search bar and some buttons in a view in my UITableViewController, but I don't know how to make that view the header? I've attached the referencing outlet to the UITableController. But currently the search bar and buttons scroll up and down with the tableview, but I want them to be the header so they stay fixed.
Here's a screen shot of what I currently have...
ok I ctrl/dragged from the view to my ViewController and created a IBOutlet, as you can see in this next image, and I added in the line to set it to be the header but it seems to give an error??
The easiest solution would be to move that view containing the search bar and buttons to being a subview of the view controller's view instead of inside the table view. Then apply your constraints so that it is pinned to the top and the table view is constrained to the bottom of the view.
If the list of elements you are displaying do not have more than one section, then you could implement the tableView:viewForHeaderInSection: delegate method. Create the headerview containing the searchbar in storyboard and return the instance. It will be always on top of the list.
Apple Documentaion

Hide Nav Bar and move Table View Section Headers

I am currently using the https://github.com/telly/TLYShyNavBar class to hide my nav bar when scrolling, it works great and is extremely simple to use. But I am using it on a table view controller so when I scroll up my section headers don't move and it looks like this.
How can I move up the section headers to the top of the screen. Or use a different way to move the nav bar when scrolling.
Thanks for the help in advance.
You could use the first TableViewCell as a custom navigation bar by adding buttons to the contentview contained in the TableViewCell. It would scroll up like any other TableViewCell. TableViewCells are mostly just a wrapper for a UIView. You can modify that UIView like any other UIView. Every TableViewCell has a property called contentview which is the main UIView in the Cell.
As an example, you could add a button to the first cell that sends the following message
[self.navigationController popViewControllerAnimated:YES];
You could call that button "Back"
https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UITableViewCell_Class/index.html#//apple_ref/occ/instp/UITableViewCell/contentView
I found a solution for this!
The problem is that, the section header stays at the top value of the contentInset. Even though the navigation bar is out of view and the tableView is visible below, the contentInset will remain same.
You would have to modify the library to increase or decrease the top value of the contentInset, according to the scrolling offset. Try this out and you may post it as a pull request in github.
Hope this helps! :)

Custom Sized Table View Still Using Offset For Navigation Bar

I am making a viewController that to input information Name (UITextField) Desc (UITextView) and then add time slots for each task (TableView) however when I add the viewController to my navigation Controller it adds an offset to the UITableView as if it were suppose to fill the page.
I have tried changing the offset but that only results in moving the massive white space further up the page and another white space appears below (I'm assuming its from the tab bar controller). how can I get rid of this offset?
I would suggest do the following:
Frame your tableView to occupy full view frame.
Use contentInset and scrollIndicatorInsets to reduce the actual table size to the proper size. In your case make sure top edge for contentInset and scrollIndicatorInsets are equal to the size of your textview and textField.
figured it out with an apple example they wrap their add a tableViewController to a UIView by adding the tableViewController as a childViewController of the UIView or if you are using storyboard u can use the container view

why header of a section of a uitableview is abnormally tall when the uitableview is embedded to a uiviewcontroller?

I would like to make a page like this (i.e. a fix segmented controller on the top, with a uitableview appending beneath it):
So, this is the way I did it: I have added a segmented controller in a uiviewcontroller, then I append a uitableview under it. Here is the diagram in the storyboard:
However, when it runs in the simulator, the header of the uitableview is abnormally tall.
I have no idea why it is like this. Am I going to a wrong direction? Thanks for any helps.
UPDATE:
This is the default setting of the uitableview. I didn't change any thing.
Select your view controller in storyboard. In the Attributes inspector, uncheck "Adjust Scroll View Insets" and uncheck "Under Top Bars".
You have placed Segment control in Tableview's header. But you had set some height to tableview section header via either xib or programmatically. That's why it leads to show this space.

UISegementController in top of UITableView

I would like to add a UISegmentController in the top of my UITableViewController, just like in the AppStore.
I have tried googleing this but either I am search for the wrong things, or too view have written about this.
How can I do this, keeping it in the top with a different design than the UINavigationBar.
For style add segmentCont.segmentedControlStyle=7; which is same as the picture style.
It may not be a UITableViewController. It might be just a UIViewController with a segment control at the top of the XIB and a tableview placed underneath the segment control. That way, you could scroll the table view without scrolling the segment control.
I believe that is a custom header cell for the tableview. You should start by created a custom header with your segmented control inside that.
I think that's a ToolBar with UISegmentedControl or just UISegmentedControl and UITableView under it. You can place them (UISegmentedControl + UITableViewController) on UIScrollView and disable scroll for UITableView. You should make appropriate contentSize for your scrollview.

Resources