Change a label inside a UICollectionView Cell by pressing it - ios

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.

Related

Can I make only a certain portion of a tableview clickable?

I'm trying to add a like button in a tableview but If I click anywhere in the tableview, it immediately goes to the detailsVC. I want to make it so when you click that like button, only that is selected. Is there a way to make it so only the top half of the tableview can be selectable or have interaction enabled, and put the button below? Or is there another way to do this. Is there a workaround or a method I am missing. Thanks
Are you sure the UIButton is added correctly to table view cell's .contentView?
Can you see it? If so it will intercept the touch events and tableview's delegate didSelectRowAtIndexPath won't get called (even if there's no handling connected to the button). If you want make the button occupy specific area of the cell you can either:
Design your cell in Interface Builder and make it a part of Storyboard/Xib
Do autolayout of the cell programmatically
Override cell's layoutSubviews and manually setup the frames

Limit the cell selection area in uitable view

I have a custom cell in table view, which allows multiple selection. Can i limit the cell selection area of a custom cell. Can i enable selection area to only the left side of the cell not the entire cell.
Please share your thoughts.
In your UITableViewCell subclass override pointInside:withEvent: method and return YES only for the points inside the area you want.
Yes, the way you want can be implemented, You make a button on left side of your cell. So Whenever you click on button your selected are will be enabled.
You do not need to implement any logic in UITableView DidSelectRowForIndexPath.
Need to manage in your button.
You can add a UIButton on the left side of your cell, by this way you can easily handle the selection of UIButton by using its tag value.
In the custom tableView Cell. The are which you want to be non clickable add a button to that area and if a tap is registered in the button the didselectitem at indexPath would not be called I have done a similar implementation myself.
My TableView Implementation

Access UICollectionView cells in ViewController

I have added some buttons to a UICollectionView like so in the storyboard:
When I build the app, I don't see anything in the UICollectionView. Why is this? I want to have only 5 buttons in there and receive their click events in the view controller. How can I achieve this?
Each cell behaves like a button. So in my storyboard I put one reusable cell with a label in it, and I add 5 items to the UICollectionView and it worked as expected.

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

Make elements in UITableVew Custom cell touchable

I have a UITableView with custom cell XIB. The custom cell has two labels and one UITextView. It all works fine, however I noticed that when I press on the labels or the UITextView, nothing happens. Its only when I press an area of the cell which is not covered by the labels or the UITextView that the cell will respond.
How can I make the cell respond to anything that is touched in the cell?
Thanks, Dan.
Yeah basically I forgot to select the interaction option in Interface Builder. lol...

Resources