Resizable and Rearrangable CollectionView Cell with Image: Swift or Obj-C - ios

My CollectionView Cell has only Image in it. I want to resize that
image by user, and while resizing the image all the cell should
automatically rearrange (I have fixed image count i. e. 22):
I have used flow layout for
collection view but limitation is that needs fixed number of
height/width.
I have added resized library separately.
I Tried by searching many libraries and doing so many demos but not
able to get the required output. I want you to suggest me either the
way should i go with or If you have done such kind of stuff then your
thought are welcome.
Thank you in advance.

Related

UIImageView streches over entire row height of UITableViewCell

Intro: Hi, I'm working on a "News" app, that uses a news API online. I want to display the content of the latest news in a TableView (Currently I want to display the title of the news item, the name of the organization that posted it (e.g: the BBC), and an image that I load from a given link). I dragged a table view in the Main storyboard, created a custom cell for a singular news item, and get all of the required information from the internet.
The Problem:
When all the data gets loaded into the TableView, the image streches across the whole rows height.
I'm trying to find a work-around for hours now. At the moment, In the prototype cell, I have a Stack View, that contains 2 labels and an ImageView, with a Vertical Axis, and a Distribution of Fill Equally.
There are no constraints on the Views inside the Stack View (the 2 labels and ImageView), and I'm not editing any constraints within the code, to keep it as simple as possible.
I also tried the constraints approach prior of using the stack view, but it gave the same result.
Image Of The Stack View
The Result in the Simulator (Rows without an image, don't have an image url provided by the api, so I just skip them).
I tried being as expressive as I can about the problem, if you are still missing some information please let me know
The problem you are encountering is due to constraint issue. The problem should be solved by unstacking the view and put constraints instead.
You can still achieve scalable application using them.
If you are confused with how to do it, refer https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithConstraintsinInterfaceBuidler.html
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/AnatomyofaConstraint.html
These should help.
I think you are in right Direction.
if you want static(fixed) Layout Follow below step.
change StackView Distribution from Fill equally to Fill
Apply StackView(leading,trailing,top,bottm) =
cell(leading,trailing,top,bottm)
set tableView rowHeight to 300 or whatever you want
if you want dynamic layout follow below step
https://www.raywenderlich.com/1067-self-sizing-table-view-cells

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 :]

UICollectionView sticky supplementary view

Assuming I'm on a chat scenario, I want user images to move along with scroll until the other user's messages appear. Some visual example:
I'm using a subclass of UICollectionViewFlowLayout to display the messages and provide that initial left offset for the messages (the sectionInset property is not working on iOS 9 for some reason) and I assumed handling a custom supplementary view to do what's shown above should not be that hard, but apparently it is :)
Some info:
I'm not using standard header/footers for flowLayout since it add a space between sections that I don't want
Found this link which is pretty interesting from performance perspective but the example is somehow incomplete (great post though)
I'm trying to avoid shouldInvalidateLayoutForBoundsChange: to return true and recreate attributes every time since chat cells can be complex in terms of size calculation.
I believe this is not a weird scenario, have anyone accomplish something like this successfully? If so, I would appreciate some pointers.
Thank you in advance.
you can use sections for each cell groups. When using sections they have to be a clear background and be customized. So message cells can be scrolled below sections and circle images on section will be on top of its cells.
As a second way, you can use circle images apart from all collection items. For this, you have to create circle images that how many required. While scrolling up/down, they have to be moved as they will be anchored on top of message cells group.
I hope it helps for you :)

Clickable tags / text

I'm working on an app that includes the names of users with their icons under an image. I'm currently using collection view in order to distribute the names. I'm using this approach since each cell when clicked will be holding the user object. However, I'm having some layout issues when it's used (please check attached image). The spacing is unusual. The desired output is the cells having a certain spacing limit between them and if any cell cannot fit, will be placed on the other line. I tried using the delegate methods for spacing by setting it to 5 however it's not working (the cell's size will be dynamic). Should I subclass and create my own Collection view Layout ? if there is any other approach without using collection views please let me know. Thank you.

iOS >> UITableViewCell ImageView Property >> ContentMode doesn't have any effect

In many cases using one of the 4 UITableViewCell 'of the shelf' styles is enough for what I need, except for one 'little' annoying thing: The cell.imageView.contentMode property is always set to Scale to Fill. If images have different ratios, it causes the cells labels to be pushed with different x per each Row. It looks ugly...
If I try to fix it in code, let's say in the cellForRowAtIndexPath method, by addressing the property and assigning it to Aspect Fit, I get no warning or error, but it simply does nothing - i.e. it remains with Scale to Fill.
That means, that if I have an app where I'm not responsible for all the images presented in the table view and therefore cannot cut them in the same size - for example, if I wish to allow the user to select images from library or download etc... - I have to use a Custom Cell, even if all it has to have is an Image and a Label.
Does anyone know how to solve this using the default styles, without subclassing UITableViewCell?
In this SO thread you have a couple of solutions for that.
However, you will find that those solutions are just another way to create a custom cell. Or you need to create an ImageView at runtime or you just create a custom cell. As far as I know it is the right way to do it. I know that is annoying but the time you take to do a custom cell is way shorter than find hacky ways to go around that issue. Don't fight the framework :).

Resources