Uitableviewcellaccessorycheckmark and Autolayout Constraints

UITableViewCellAccessoryCheckmark and AutoLayout constraints

This behavior is by design.

The simplest way to get the behavior you want is to set an empty accessory view on every cell which will move all the content to the left the same distance as the checkmark.

Defining Constraints for UITableView with UITableViewCellAccessoryType.DisclosureIndicator

It is not a build type. The answer in the link you're refering is saying that you should set a non-nil view to the accessoryView property of the UITableViewCell instance. Eg. yourCell.accessoryView = someBlankView.

Weird animation behaviour while using autolayout in .xib

Fixed the problem by updating the frame and then calling the [self layoutIfNeeded];
Nothing will work if you miss [self layoutIfNeeded]; function call after updating your frames.

How to change constants in AutoLayout constraints that are created in IB programmatically?

I have assigned a variable similarly as you would for any UI element - NSLayoutConstraint.

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelConstraint;

And in the code you would do something like:

self.labelConstraint.constant = 10;

How to center text in a UITableViewCell when accessory is UITableViewCellAccessoryCheckmark

iOS 8+ solution:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.textLabel.text = ...;
if (/* your condition */) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
cell.layoutMargins = UIEdgeInsetsMake(0, 40, 0, 10);
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
cell.layoutMargins = UIEdgeInsetsMake(0, 10, 0, 10);
}
return cell;
}


Related Topics



Leave a reply



Submit