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;
Related
I need to dynamically set a container height. This is in the event of using a container view with view controllers which may change.
let frame = viewController.view.systemLayoutSizeFitting(UILayoutFittingCompressedSize)
containerHeight.constant = frame.height
view.layoutIfNeeded()
I am using the above code for getting the required height of the new view controller so that I can set the container views height.
This seems to work fine on any view which doesn't contain a scroll view. If the view has a scroll view so for example I have a view with a title, tableview and button at the bottom of the tableview. The height calculated doesn't account for the tableview.
Is there anything special I need to do when calculating the height of a view which has a scroll view
I have a question - how to add a view as a subview of UITableViewCell but on top of all other views?
Here is an example of what I'm trying to achieve:
The image should scroll with the cell - save it's position relatively to scroll view (table view in this case).
If the cell is to small in height then the emojis overlay will be cut by the cell on top of current one, so how can I add this emojis overlay as a subview but at the same time display it on top of every cell? I've tried bunch of variants for now and nothing is working for me.
Just adding as a subview of the current window is not working for me because this overlay should scroll with the cell.
Tried code:
view.layer.zPosition = 5
cell.contentView.insertSubview(view, aboveSubview: cell.contentView)
cell.contentView.bringSubview(toFront: view)
UIApplication.shared.keyWindow?.addSubview(view)
Try to set cliptobouds = false for your cell.contentview and cell itself.
Otherwise if it is single overlay which you want to be on top of every cell then better implement UISrollViewDelegate and position the overlay accordingly.
When I create my 1st CollectionView using storyboard the CollectionViewCell has default insets from top(in size inspector it shows zero but it bit down from top of CollectionView) and I cant move it to top, but when I create a second CollectionView and further CollectionView its cell has no insets from top?
In your storyboard, uncheck Adjust Scroll View Inset of the view controller containing the collection view.
I have a UIImageView on my ViewController, I also placed a CollectionView below it in storyboard. I populate the collectionView and with data and when I run the app, only the collectionview section scrolls, while the image view remains static on the page even while scrolling through the list of collectionView items. I wan the whole screen content to scroll up when the top item of collectionView is reached. How do i do this in objective-c. If it will be with a scroll view, how do ii implement this?
Images below illustrate how it is on iPhone music app in the radio tab section, which contains banner and collection view below, when i scroll up the banner moves out of sight above, and the collection view appears and the remaining content. that's what i want, the banner shouldn't be static
Have a UIScrollView as a parent for for image view and collection view. And your image view and collection view inside the scrollview. Now set contentSize property of the parent scrollview.
var size : CGSize
let height = imageView.frame.height + heightOfCollectionView // heightOfCollectionView is height calculated from total number of cells/sections present in collection view
size = CGSizeMake(self.view.frame.width,height) //assuming
scrollView.contentSize = size
Set this is viewDidLayoutSubviews of your view controller
By looking at the screenshots you can create a collectionview cell just to present that image view and put that cell at the top.
Have a storyboard w/ a TableViewController that has a grouped table view. In the first section, I want the cells' width to be smaller than full-screen. To accomplish the latter, I have a custom UITableViewCell class w/ the following method:
- (void)setFrame:(CGRect)frame {
frame.origin.x += NAME_TABLE_VIEW_INSET;
frame.size.width -= NAME_TABLE_VIEW_INSET;
[super setFrame:frame];
}
That works fine. The issue I have is that a UITextField subview that I dragged into the storyboard cell does not adjust its width automatically to the new cell frame size.
I've tried sub-classing UITextField and ensuring that the autoResizingMask is set properly, and I've tried using [super layoutSubviews] in the setFrame method above. None of these approaches works.
Any suggestions on how I can get the text field to adjust its width automatically while still using this storyboard approach?
The solution for this was to add a separate table view in the header of the tableView provided by the table view controller. Specifically, add a view object to the top of the table view in IB; add a table view as a subview into that view; change the width of the new table view's cells.
Note that this problem exists only because I wanted to use a table view controller, which defaults each cell to the width of the screen. A view controller could have been used, but then you cannot add a table view w/ static cells as a subview.