UiCollectionView and expandable view - ios

I have got UiCollectionView with rounded cel (on iPad 3-4, on iPhone 1-2).
I need show view below any clicked cell as on screen (with change text length).
I spend a lot of time thinking about this.
My first step was make custom cell that show the frame below cells, but it was wrong step.
Rounded cells changed padding when this was added...
I am using RAReorderableLayout, additionally to swipe cells.
Any idea?
Please help me with this problem.

You could make it a custom UIView, which has 3 parts: the part before the tick, the image with the tick and the part after. Then in the delegate method for
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
you can call an update method on this view, that will change the widths of the three parts according to the selected index in the collection view.
You could even send the width of the collection view cell in this update method to use it for calculating the right widths.
Hope this helps! Good luck!

Related

ios dynamic cell height determined by photos and text

I am trying to make a feed very similar to Instagram, everything works however I have ran into a problem I cannot figure out how to solve.
This feed will include photos that are of different sizes, e.g squares, portrait photos and landscape photos.
The problem is I want to resize the UIImageView in the UITableViewCell to match the size of the photo, and also have the UILabel resize depending on how much text there is.
The UIImageView's width will always equal the width of the screen, like Instagram, and only its height will change to make sure the photos are of correct ratio.
Here is a photo of my current cell:
I have tried using autolayout, however I couldn't understand how to get it to work with a UIImageView that will change ratio, from being landscape orientation to portrait orientation etc.
I have also tried in this method here :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
Manually trying to calculate the size:
//An example of trying to calculate the size of a view in my cell
cell.cellView.frame = CGRectMake(0, 0, self.view.frame.size.width, 400);
However, it has gotten extremely complicated that way because I don't know how to resize the actual UITableViewCell height to be unique for every cell.
I have also looked at the following resources:
Link 1
Link 2
Link 3
Link 4
Link 5
All of these are tutorials on dynamic cell height, however they do not seem to explain what to do with my situation.
It would be great if anyone could please suggest what I can do to achieve the Instagram style feed with unique cell heights and unique content size within the cells.
As far as I can tell from looking at the app, each item in the feed is actually a whole section in the tableview. The giveaway is the way the username/location/time header 'snaps' into place at the top and everything else scrolls under it. That's a viewForHeaderInSection. Each section then has 2 or more rows: the photo, the toolbar, the hearts/likes info, and then one row per comment.
So instead of making one giant cell and trying to lay everything out inside it, use multiple cells. You can prototype each cell in the storyboard with a unique reuse identifier, then just figure out what kind of cell you're looking at and dequeue the appropriate one from the storyboard.

Is it possible to keep a collection view inside another collection view?

I have a scenario where if we click or select any cell inside a collection view which is in vertical scrolling, it should display a single row horizontal scrolling below the selected, this should applied for all the cells, so I have created a collection view inside the view controller, and I thought of creating another collection view inside the method:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{}
Because here not only collection view is creating, but also the next cells are moving down. Hope you understand the situation. But I was struck here.
I'm not getting any idea how to write code here,
1) Is my approach is correct,
2) If yes, give me some instructions how to achieve this?
3) If I insert a cell, it will insert a cell but it should be horizontal scroll as shown in the image i posted. so Help me out ??
One way to achieve your design would be:
Add two type of UIcollectionviewcells to collection view
cell1: cell1 is the normal cell on which you click.
cell2: You will insert this cell at indexpath + 1 in collectionview when tapped on normal cell
Add a scroll view to cell2. with horizontal scrolling or collectionview.
cell2 will be the datasource and will contains logic for that view.
This will make a lot easy for handling events.

position custom cell in a tableview not fully showing a cell

Okay What i want to do is position a custom cell so that the cell looks like only a portion of it is shown in the UITableView. When you swipe it to the left it goes to a new viewcontroller that allows the user to add details for a new cell. My question is how do we position the UITableViewCell to show only a portion of it in the tableView?
What i want to do is position a custom cell so that the row is not shown fully like about 1/4th or 1/2 its actual length only in the table view
here is an app with the functionality i'm trying to implement this is the image url as i can't post images yet
http://a3.mzstatic.com/us/r30/Purple6/v4/01/16/ec/0116ec99-0206-d125-7d27-d5956b918635/screen568x568.jpeg
I want to implement my cells just like how they implemented their expenses in cells, the cell is positioned according to the amount in it ,if the amount is high the cell is placed further to the left else only 1/4th of the cell is shown(empty cell no expense )
Can we achieve this by making an imageview in a customcell and then changing the x-axis of the image view according to the amount entered in the cell? Thanks in advance
For this, I would do it this way :
For each of my model cell I add a state, in the delegate of UItableView i use heightForRowAtIndex to set the size depends of the cell's state.
To not show extra view (when the cell is cliped) use :
[myCellview setClipToBounds:YES];
I think it should do the tricks. Even if it's not the best way to do it!
Solved it i Just had to add a scroll view to the cell's content view and then add a view containing the color to the scroll view. So its coding is similar to the swipe deletion in 'UITablView'
https://github.com/TeehanLax/UITableViewCell-Swipe-for-Options
this repository helped me out, i only had to make a few changes otherwise that was it thanks for all your suggestions :)

Change cell height while scrolling a UITableView

Is there anyway to change the height of a cell dynamically whilst scrolling a UITableView?
I need to change the height of a number of cells when the scroll position reaches a certain point as the user drags it down past the top. I can do this successfully by issuing a reloadData, however it's very abrupt since the cells just vanish.
I've also tried reloading the cells and running the begin/end updates on the table view, however in both cases the animation sends the scroll view back to the top.
I'd like to animate the cell height change without messing up the current content offset of the drag in progress.
Tim
Use the UITableViewDelegate and implement the method
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
This solve your issue?
If it is not solving your issue, try to explain better your goal, with examples/images.

How to avoid cells background image from hiding the separator line between rows

In my table view I am using custom image for the UITableView cell's background. It works perfectly except for the fact it hides the row separator. And now there is no row visible.
Is there a way to increase the distance so that cells will get separated.
Please help!!!
Thanks,
Without seeing what you are seeing, it's a bit hard to tell. That said, you could try adding the separator to the image so that it shows up in the cell.
If you want to change the height of the cell, implement the -tableView:heightForRowAtIndexPath: method in the table view delegate. Just return the correct height for the row at indexPath. I believe there is also a way to set the rowHeight in the table view properties in interface builder if all cells will be the same, but I tend to stay away from IB when possible.
As far as my knowledge you can add a line image to the cell as a footer.So that you can see the separator
I believe you have to override the -setFrame: method in your custom cell and return the same frame with height minus 1 pixel.
Also be sure to call [super layoutSubviews]; in your -layoutSubviews method if you have overridden this method with some custom implementation.
LineSeparator may be invisible to you because of your background image in your cell. Try to change the style of your separator.
Alternative Way:
Otherwise You have to add a one pixel line to the bottom of your Custom cell background image by your designer and if it's still not visible in your tableView, then you have to increase a height for your cell in heightForRowAtIndexPath: method.
Make sure your view if you have one that is inside your Cell is exactly the same size as your cell's size.
Make sure:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
is setting your cell heights correctly for all cells.

Resources