TableView - Header and section are not correct - ios

I have some issues with header and section here. My view is below:
Custom navigation with transparent.
TableView frame = screen bounds, contentInset top = 64.
TableView with header clear color.
TableView has 1 section view (view has 3 tab).
When I scroll tableview, section keep under navigation (perfect), but cells are scroll from section to top screen. I want cells only scroll in section, not to top and under navigation bar.
Can I help me? Thank you so much.

This is because the table view clipsToBounds by default is false, which means it will be rendered outside the table view bounds.
A solution:
tableView.clipsToBounds = true

Related

How I can delete this space between tabbar and collectionView?

How I can delete this space between tabbar and collectionView?
I have a tabbar -> viewcontroller -> collection
this purple rect it is part of ViewController, but the problem that collection view has the same frame as vc.
Here log:
print("Frame.height: collectionView ->\(collectionView.frame.height) --- view \(view.frame.height)")
Terminal
Frame.height: collectionView -> 812.0 --- view 625.0
Are you changing the height of the standard tabbar?
If so, you're doing it in the wrong place, and the ViewController might compute its height before your change on the tabbar. Try modifying the height in viewWillLayoutSubviews.
you probably need to adjust the bottom constraint of the collection view to be the top constraint of the tab bar

How to show tableView to top when scrolled

In my project,
In the view 'Top' side is for one UIView and below it a tableView. I want to show tableView to top when scrolled and hide the tableView.
func scrollViewDidScroll(_ scrollView: UIScrollView) {
self.topView.isHidden = true }
Please give me solution for how to show tableView to top when tableView scrolled.
Below is the screenshot
[![enter image description here][1]][1]
in this view bottom is tableView and top is UIView.
Below is the storyboard screenshot.
The simplest solution is to set that topView as tableHeaderView.
self.tableView.tableHeaderView = topView
Now when you scroll the tableView topView will goes up with it. Also no need to implement scrollViewDidScroll now.
Select your tableview in your Controller of Storyboard
Select your TableView
Go to Attributes Inspector on the right panel of Utilities
Set Style to Grouped

View not reaching the bottom of the device screen using Autoresize Subviews

I have a view controller that has a button at the top center, and a view underneath which will have the collectionview inside. I want this collectionview to scroll separately to the top view (so it scrolls underneath that top section).
This works fine but the view with the collectionview doesn't reach the bottom. You can see in the screenshot I gave the superview a red background - the collectionview doesn't reach to the bottom of the view. All the constraints are fine.
It works if I uncheck "Autoresize subviews" in the Interface Builder for the UIView inside the View Controller but this then makes all the cells and any navigation bars I add inside that view 1000px wide. Why is my view being shortened - and how can I get the best of both these scenarios? A View that hits the bottom of the screen and all the cells/navigation bars the width of the view?
Constraints for the view:
Constraints for the collectionview:
I did have a tab bar too, and the gap is the exact height of my tab bar.
Anyway I fixed this by putting:
self.extendedLayoutIncludesOpaqueBars = YES;
self.edgesForExtendedLayout = UIRectEdgeBottom;
in viewDidLoad method.

How to clip table view cell to view above

I have custom tableViewCell and View above it in tableView. After taping on button views height increase and cover cell's view. How to clip cell to bottom of view for changing position of cell and don't allow view to cover cell?
I tried to override setFrame: method in my cell. But it doesn't work.
If the view above the cells is a table header view, you should reset that view as the header after you increase its size. So, if you're view was called myHeader, you would do this after changing the size ,
self.tableView.tableHeaderView = myHeader;

How to add a search bar at the bottom of a table view in Xcode?

I am developing an iOS application, and I want to add a search button that initiates a search of a table view. When searching, the search bar should not be scrolled with the table cells.
To make a search bar (or any view really) "stick" to the top or bottom of a UITableView there are two approaches:
Adjust the frame of the table to be the view height minus the height of your bar, and then set the bar's frame to {0, 0, CGRectGetWidth(self.tableView.frame), CGRectGetHeight(self.tableView.frame)}, which would position it statically at the bottom of the view. If you are using a stock UITableViewController, you'll need to do some additional work because self.view and self.tableView both point to the same object. You'll need to set a new UIView to self.view which will then be the container for the table view and your search bar view.
Add the bar as a subview of table, then implement UIScrollViewDelegate in your controller and use scrollViewDidScroll: (which fires whenever the user scrolls the view) to update the bar's position. The new position would be something like:
CGRect adjustedFrame = self.searchBarView.frame;
adjustedFrame.origin.y = self.tableView.contentOffset.y + CGRectGetHeight(self.tableView.frame) - CGRectGetHeight(self.searchBarView.frame);
self.searchBarView.frame = adjustedFrame;

Resources