UICollectionView Not Showing Cells Completely. Last Cells Are Not Getting Shown Completely - ios

I have created a custom gallery with collection view which shows all the Photos of camera roll from photos app. I have made a custom cell class. Now the thing is happening like below - : It is not showing my last row of cells. Please folks help me out with this.
It could be great for me. I am not using Constraints for my UICollectionView. I am not able to figure out ; how to give content size to UICollectionView like UIScrollView.

Guys some time problem seems way bigger than they looks.
I figure it out and yes it solved mine.
I was searching the simple and short solution for this and I found same related question below - :
UICollectionView not able to scroll to see the entire last row
and the answer given by #Carpetfizz really worked for me.
I was using auto layout thats the reason it was solved ;
If you are not using auto layout it won't work for you.

Please enable Auto layout in your xib file

If you are using constraints, create NSLayoutConstraint IBOutlet for height of collection view. Then do this thing
[collectionView reloadData];
layoutConstraintCollectionViewHeight.constant = collectionView.collectionViewLayout.collectionViewContentSize;
It will automatically resize you collection view height and can scroll upto last item.
For non-constraint design, use this
collectionView.frame = CGRectMake (x,y,w,h); // Here calculate your height and width for collection view
[collectionView reloadData];

Related

Stretchy header view for UICollectionview and minimize UIImageView while scrolling up

I am trying to achieve a certain layout that looks like twitter and many other apps. Some people do it in UIVIewLayouts but I want to achieve it using this way (if possible ). As you see in the attached image. I have Header, and cells in the collectionview.
While scrolling up I want to minimize the imagview avatar inside the headerview. -> ( ViewForSupplementaryEelementHeader )
while scrolling down, I want to make the top UIImageview to be fixed to the top and stretchy
Thank you all in advance
*ps I am doing all of this in code nothing with storyboard and I dont want to use it at all.
Please advise me how to access these imageview while scrolling up and down.
I think this is the example you are looking for
https://github.com/sunlubo/StretchyHeaderView
This will add only tableview in storyboard...other all the work is done through coding

UITableView height for dynamic cells

In my current project i'm trying to display data in a table View, however the former view does not take up the whole screen just a part of it. It's number of cells depends on an external json and the height of the cell is dynamic. Sadly there is no inbuilt way to use auto-layout(at least i think there's not) to expand the tableView depending on it's cells.
In the following picture there's an example of how one of these table views should look like:
And here's an example how the table view looks like using the autolayout:
Is there a way to expand the tableView to it's full size?
I've tried to follow various other questions but none have fully helped me, for exampled i've tried to this solution which sadly did not help me :[, creating a subclass of uitableview and overriding its intrinsicContentSize did not do the trick either.
Any help is much appreciated.
-Jorge :]

Increasing the width of UITableViewCell in a grouped TableView layout

I am trying to get rid of the cell margin on the left and right of a set of cells within a group.
I have looked around and have found this question/answer
but this seems like it could cause plenty of problems down the track.
I also tried changing the cell.indentationWidth and cell.indentationLevel but these seem to change the indentation within the cell, not the cell itself.
Is there an Apple approved way of changing these cells to stretch the width of the Tableview??
Thank you in advance, your help is much appreciated.
Scott
Do one thing. add label or any other control in this and then add that in your UITableviewcell.
Then you can give whatever format you want according to your need.

UITableView in storyboard not updating content size on rotation

I'm working on project targeted for iOS 6 that leverages storyboards and auto layout. In the storyboard there are many places where a UITableView is added as a subview to a view controllers view. This table view uses prototype cells from the storyboard.
The issue we're running into is that if the view controller is initially loaded in landscape orientation and the device is then rotated to portrait, the table view begins to scroll both vertically and horizontally. The table views cells are drawn with the correct dimensions but there is additional white space to the right.
It appears that while the frame and bounds of the table view are being updated to the correct size on rotation, the table views content size is not. Regardless of any update rotation change the content size remains the same dimensions.
The issue doesn't present itself if programatic table view cells are used.
A few garish work arounds I've found, 1.) calling reloadData or reloadRowsAtIndexPaths:withRowAnimation: 2.) manually setting the property contentSize.
Both of these seem less than ideal.
I've added this
link to a dead simple sample project which demonstrates this issue. The only changes made are to the storyboard and the main view controllers implementation.
Before rotation
After rotation
I'm having the same issue - can't seems to find any documented answer related to this. I ended up manually modifying the UITableView contentSize like you mentioned in:
- (void) viewWillLayoutSubviews
{
self.tableView.contentSize = CGSizeMake(self.tableView.frame.size.height, self.tableView.contentSize.height);
}
I ran into this issue today and filed a bug report with Apple.
Appears that if you are using a custom cell with a UI element AND autoLayout, the UIScrollView content size is having problems.
If you remove all UI elements, OR turn off autoLayout, OR use a factory cell (basic, etc), all works fine.
Same issue I have rectified in my project.
I guess this is a bug in Storyboard.
Then I have solved it by manual coding in willAutorotate method by setting
tableview.contentsize = CGSizeMake(tableview.width, tableview.contentsize.height);
Hope this will work for you as well.
If you find any apple documentation regarding the same then please update me as well. Till then you can use the same solution.
Appears that if you are using a custom cell with a UI element AND autoLayout, the UIScrollView content size is having problems.
I had to turn off AutoLayout for my custom UITableViewCells to be able to scroll to the bottom on updating the data and then [self.tableView reloadData].
With AutoLayout turned on, the tableView.contentSize was being updated, but I still wasn't able to scroll to the bottom unless I rotated the device.
I found the following to work for me:
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
dispatch_async(dispatch_get_main_queue(), ^{
self.tableView.contentSize = CGSizeMake(self.tableView.frame.size.width, self.tableView.contentSize.height);
});
}
Notice the async dispatch: if that line would be executed synchronously then the contentSize change would trigger another layout pass before the current one would have completed. This triggers an exception:
Auto Layout still required after sending -viewDidLayoutSubviews to the
view controller.
Usage of Constraints helped me. Since you are using Storyboards, it is really easy to set Constraint values for all edges, so UITableView will always fill the whole ViewController (of course if UITableView fills whole ViewController) regardless of device orientation.
I had the same problem.
I found this link. When I tried to implement this I did not find the Auto-sizing attributes for my view then I clicked on Master View Controller and then clicked on the File Inspector and uncheck Use Autolayout and then go to Attributes inspector auto-resizing should be there then you can change the attributes how you want it.
I am sure you must have managed to figure this out.

scrolling custom UITableView slow

I am facing the following problem :
I have a custom UITableView with each cell having an image with some text. When, I scroll the UITable, for each section, the respective image will be shown on top of the UITable.
The scrolling is little slow and seems to be sticky.
Can anyone give me any idea how to improve this ? Thanks
There is a sample code from apple on lazy image loading: http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html
I think that will help you a lot... You also need to watch for reusing cells properly..
if U have too many subviews in cell,it must be slow when scrolling,apple says it。

Resources