Option for deleting UICollectionViewCell on longpress of anUIImageView placed inside it - ios

Scenario:
I have a programatically created UICollectionView with flow layout inside which a cell contains a UIImageView and a UILabel on it.Now,On Long pressing on UIImageView,a cross image should comes on top right of the UIImageView and on tappig on it, The entire cell should be deleted.I have done some research on this.But it will me more helpul if someone share their ideas ...

Add a tapGestureRecognizer to the UIImageView
set the tapGestureRecognizer tag equal to indexPath.row so that you can determine the cell thats need to updated and deleted

Related

Change a label inside a UICollectionView Cell by pressing it

can anyone point me in the right direction of trying to edit a UiCollectionView cell by pressing on it? I have 3 labels inside a XIB, and that is presented in the UICollectionView. I would like to have the user be able to edit it when they press on a certain cell. Maybe even pop up like below.
Thanks all
You should probably use a UITextField instead of a UILabel to enable user interaction. Then link that UITextField to your custom UICollectionViewCell class.

iOS Accessibility for CollectionView in a TableViewCell

I'm currently working on the accessibility of our project, and here is UICollectionView that is put into a custom UITableViewCell. This CollectionView has tens of cells that are arranged in multiply rows rather than one row.
It raises an issue that when you have voiceOver on and move the focus between the collectionViewCells by swiping left or right, the system thought you are swiping between tableViewCells, since collectionView is in the tableView, and the contentOffSet of the tableView will be changed according to the tableViewCell size, instead of the collectionViewCell size.
CollectionView is already put in the the tableView and I don't think I can change this. So just wondering has anyone met this case before and is there anyway to make the collectionView accessible as normal?
This is a known bug in Apple's SDK (sorry, I don't have a bug report reference) when nesting a collectionView inside a tableView. After some experimentation, I was able to work around it by using a UIView as a wrapper for my collectionView before adding it to my UITableViewCell's .contentView
UIView *wrapperView = [[UIView alloc] initWithFrame:cell.contentView.bounds];
wrapperView.accessibilityElements = #[collectionView];
[cell.contentView addSubview:wrapperView];
[wrapperView addSubview:collectionView];
Just fix the problem by reconstructing the whole page, here are 2 things do not do to make your app more accessible:
Avoid adding a subview directly to the tableView/collectionView like
[tableView/collectionView addSubview:yourSubView];
Avoid adding a vertically scrollable collectionView to a tableViewCell.
Adding a horizontally scrollable collectionView to a tableViewCell seems will not cause any issue.

Disabling touch interaction of Spaces between Custom table view cell

I use custom cells of subclassing UITableViewCell in a table view. And There must be space between cells. I succesfully add the space with adding a subview that I called SpaceView into the content view. But When I touched the spaceView, it is perceived as I touched the cell. And didSelectRow method called. I tried to set spaceView's UserInteractionEnabled==NO. But It doesn't work.
So my question is; Is this the right way I used to add space between cells ? Should I try to add cells for making the space ? or If its the right way, How can I prevent calling "didSelectRowAtIndexPath" method when I touched spaceView ?
like Inder said below, u can use an UIButton to solve the issue.
1) in your custom cell: at the bottom of your custom cell add a blank UIButton with the height u actually need between cells, and customize its background color according to your needs.
2) in cellforrowatindexpath: disable button of each cell. (or you can also do that in Interface Builder of previous step)
result: u have a clear disabled button that will appear as required space between cells.
Make your spaceView as UIButton (I guess it's UIView right now)
When you add UIButton that touch will be consumed by the button thus touch won't be passed to it's parent.
OR
I'm not sure if it will work or not, you can add tap gesture to your spaceView

How can i set an imageview over 2 table view cells

I'm trying to construct a register page similar to the one used by instagram or foursquare , the problem is they have a special mechanism in a table view where you can set your avatar , like so :
It seems like an imageview was added above 2 tableview cells , obviously the insets are modified so the line doesn't touch it , but i can't seem to place the image or modifiy the tableview cell width .
How can i achieve this ?
This is probably a single cell with 3 UIImageViews, 2 UITextFields, UIButton and a dividing line being another subview (perhaps thin UIView). You can easily achieve this with a subclass of UITableViewCell.
Update: review this question for steps how to achieve it in storyboard: How do you load a prototype cell from a storyboard? You would need IBOutlets for UITextFields and IBAction for UIButton.

Why is my UITableViewCell imageView image disappearing?

I have an image in a cell's imageView, but If I scroll the uitableview up so that that particular cell goes off of the screen, then let it come back down, the imageView disappears.
How can I fix this?
The left column is the tableview untouched, the middle column is the tableview pulled up, the right column is the tableview released
As Kevin mentioned, your problem may be in the way you set the image. Are you creating an imageView and assigning it to the cell's imageView property or the image inside the property? without looking at the code, I would suggest checking what happens when the cell is created. in the cell == nil case. Hope it helps.

Resources