iPhone - UITableviewcell label movement when press Editing - iphone

In the normal behavior when Edit is pressed, the red delete circles appear from the left. This shifts the entire cell to the left.
When this happens, custom labels on the far right of the cell overlap the cell movement touch area.
The solution is to move custom UILabels to the left when edit is pressed.
How is this done?

Assuming your UILabel is being added to the contentView of your cell, just make sure your subviews (whether a UILabel or other UIView-derived object) have their autoresizingMask set up to allow flexible width (UIViewAutoresizingFlexibleWidth). Also, your left subviews need UIViewAutoresizingFlexibleRightMargin, while your right subviews should have UIViewAutoresizingFlexibleLeftMargin.

Related

Constraining UITableViewCell to change when editing

I have a UITableViewCell that has a UIImageView 20 pts in from the left. When I tap "Edit" to edit the contents of my UITableView and the red edit circle comes in from the left, how do I properly set up my constraints so the left of my UIImageView is constrained to the right of that red edit circle view?
Note: I'm doing layout in code, not using Storyboards or xibs
This would be handled automatically if you make sure that your views are subviews of the contentView in the UITableViewCell and your constraints are applied to the contentView.

set margin to collection view's cell

I'm beginner with collection view,
I need to create cell like this
Can I do it from Storyboard?
I want to add margin of cell = 4 or 5 in the top, bottom, lift and right in iPhones and iPads of all sizes, or I if need to do that programmatically How I can add the contents of the cell like the image above?
There is no "margin" here. There is simply a rectangle with a shadow, and everything else is drawn in front of it. The simplest solution is probably a custom UIView that draws itself as a rectangle with a shadow. Make that the content view's direct subview, and everything else in the cell is a subview of that. The inset of the rectangle-with-shadow within the cell's content view can be determined by autolayout (and the position of all the stuff inside it can be determined by autolayout too).
Thus it was trivial for me to obtain this sort of thing:
And of course you can tweak the border color, the background color, and so forth.

UIButton in custom UITableViewCell not registering tap

I have a custom UITableView, with custom UITableViewCells that are dynamic in height. I create the skeleton of the custom cell in storyboard, which includes (for simplicity) just a label at the top (static height), a label in the middle (dynamic height), and a label at the bottom (static height).
I have a tap gesture setup on the bottom label.
The problem I am having, is the tap gesture on the bottom label does not work (all the time). It seems to work when the middle label is shorter (2 lines), than when it is longer (2+ lines). If I move the label to the top, and anchor it to the top of the superview, the tap event gets registered every single time.
Has anyone else experienced this, and perhaps has a solution to this problem?
It seems to work fine if I add the label programatically.
Are you sure your bottom label is not occluded by the label in the middle? Labels have default transparent background, maybe your bottom label is visible but not accessible for tap gestures. Try downsizing your middle label or add tap gesture compatibility to middle label also so that you understand if it takes away the tap gesture from the bottom label. If this is case you can fix it by bringing bottom label to front
[tableCellView bringSubviewToFront:bottomLabel];

UITableViewCell Grouped Frame extends beyond cell

I'm creating a custom cell setup. My issue is when I add a subview to the cell and make it align to the right of the cell it goes beyond the right edge of the cell. Apparently the frame goes beyond the visible edge of the cell and onto the background.
I need the right edge to be the inside of the cell. What should I do?
I had to do it manually and just detect if the device was an ipad and change the frame.

Covering space from one UITableView's cell with another one

The design of the UITableView is something like this:
I want to make my cells with a tiny triangle, like in a comic book. The thing is, how can i add the triangle to the size of my custom cell? The common rectangle size wouldn't work if i want the user to be able to tap that little rectangle.
And how can i make the opposite? I want the triangle to cover the space of another cell, so tapping the little triangle of the first cell, covering part of the second cell's rectangle space, would activate de first one. This is, substracting a little triangle from the cell's space.
Not sure it would work, but building on user697562's comment, you could try the following:
Add a small UIView to the table cell to represent the small triangle
Rotate it using its transform property, making sure that, along with its frame, it will have the proper placement.
Add a UITapGestureRecognizer to the UIView
Add an instance variable to the view to save the indexPath of the cell it's in (or even the above cell, since it will be associated with the above cell). This way when the gesture recognizer is triggered, you know what row you're in.
Write the action method associated with the gesture recognizer to do the same thing as tableView:didSelectRowAtIndexPath: would do for the above cell.
Set the separatorStyle property of the UITableView to UISeparatorStyleNone, so that it won't draw the lines between cells. If this doesn't work just set the separatorColor property to your table cell's background color.
Draw a border along the top & bottom of the cell, accounting for the triangle.
Good luck with it! Let me know whether it works if you try it.