It doesn't seem to work setting the "inView:" attribute of "presentPopoverFromRect" to the cell itself.
If the inView: is the cell, be sure to set the FromRect to cell.bounds instead of cell.frame.
The cell's frame is relative to its super view and not the cell itself. Also, the popover is shown next to the specified CGRect (not in).
Related
I have tried to find view position inside collectionViewCell relative to ViewController using
let cellFrame = cell.convert(cell.frame, to: self.view)
but it calculates wrong because I have section insets and collectionView offset on top. I have tried manually adding all offsets but it still hasn't gave me correct position. If I set it correctly for one device it doesn't show nicely on others. This is my layout.
I have a UITableViewController and I put a UIView right under the navigation item and above the actual table. The problem that I have is that the view scrolls with the tableview.
How would I get it to behave exactly like the nav bar, and have the items in the tableview scroll behind it.
Rather than having the view scroll, it should remain in its position and have everything go behind it. Sorry for reiterating, but I've found thats necessary sometimes.
The view you're placing above the cell in the storyboard becomes the table view's tableHeaderView.
You can make the header view appear fixed by resetting its frame.origin to the table view's bounds.origin every time the table view lays out its subviews:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
UIView *header = self.tableView.tableHeaderView;
CGRect frame = header.frame;
frame.origin = self.tableView.bounds.origin;
header.frame = frame;
}
Result:
Assuming you don't want the map view to move then you could set its user interaction to false.
Alternatively you could set the header of your tableView (if you only have one section) to the map view.
I want to move the tableViewCell down a little when the UIView is expanded.
I have some detail information initially hidden inside the view. Now if the users are interested in the detail information, they can click the button on the view to show the detail information, but the frame of detail intrudes onto the tableViewCells, so I want to change the location of tableViewCells to move it down a little to fit the view's frame.
Is possible to change the frame of the cell in the cellForRowAtIndexPath?
I have tried it, but I get an error.
The following picture says when I click the arrow image, it shows the detail information.
Thanks.
Note: My UIView is inside the UITableView, so changing the frame of UITableView doesn't work.
self.tableView.frame = CGRectMake(self.tableView.frame.origin.x,self.detailView.frame.origin.y + self.detailView.frame.size.height,self.tableView.frame.size.width,self.tableView.size.height - x);//set value of x according to your need
I hope this would help.Thankyou
You should change contentInset of the UITableView:
youtableview.contentInset = UIEdgeInsetsMake(x, 0, 0, 0);
You should fix that x value to deal with your custom view height.
Good luck.
You could change the ContentOffset of the UITableView.
self.tableView.contentOffset = CGPointMake(0, self.tableView.contentOffset.y + 44);
I need some help.
I have UIcollectionView, I am using scrollToItemAtIndexPath:atScrollPosition:animated: Method. I need somehow to recognize if collection view will scroll to position or if item on needed position and will no scroll.
Another words, if scrolling will not start, scroll view delegate methods will not be called.
Thanks for help
How about checking if the indexPath you're interested in is in [UICollectionView indexPathsForVisibleItems]?
You can also use layoutAttributesForItemAtIndexPath to get the exact frame of the cell to determine if its partially shown.
You can use
CGRect cellFrame = [collectionView.visibleCells.lastObject frame];
CGRect collectionViewVisibleRect = collectionView.bounds;
collectionViewVisibleRect.origin.y = collectionView.contentOffset.y;
if (CGRectContainsRect(collectionViewVisibleRect, cellFrame))
//no scroll
else
//scroll
That does not takes into account contentInset that you might have.
I am using a UICollectionView with fixed size CollectionViewCells. I display this CollectionView in a popOver with an UIPopoverController.
My goal is that the popOver automatically resize to the CollectionView's content. So if I only have 4 cells, than it should be small. And if I have more cells, it should be bigger. I want to avoid the empty space left in the popOver.
So I don't want a fixed popOver size, but a variable one depending on the number of cells in the CollectionView.
Any suggestions?
I had a hard time figuring this out myself but just got it finally. You have to access your Collection View's collectionViewLayout property and then use the collectionViewContentSize method to get the size of your content. You can then use those to resize your Collection View by setting it's frame.
CGRect rectangle;
rectangle = _collectionView.frame;
rectangle.size = [_collectionView.collectionViewLayout collectionViewContentSize];
_collectionView.frame = rectangle;
Now that your collection view is sized to it's content, you can set the popOver's size based on the collection view size. It may look something like this.
popOver.frame = _collectionView.frame;
or
[popOver sizeToFit];