Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9101609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:10:29+00:00 2026-06-17T01:10:29+00:00

I have custom subclass of a UITableViewCell with some constraints set. Problem is when

  • 0

I have custom subclass of a UITableViewCell with some constraints set.

Problem is when I try to change size of one view like this:

CGRect frm = CGRectMake(0, 0, someValue, 30);
cell.indentView.frame = frm;

other views, which depend on cell.indentView width, are not moving at all.

What can be the case?

This code will work:

// enumerate over all constraints
for (NSLayoutConstraint *constraint in cell.indentView.constraints) {
    // find constraint on this view and with 'width' attribute
    if (constraint.firstItem == cell.indentView && constraint.firstAttribute == NSLayoutAttributeWidth)
    {
        // increase width of constraint
        constraint.constant = someValue;
        break;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:10:30+00:00Added an answer on June 17, 2026 at 1:10 am

    It’s because you cannot just change the frame of an object that has autolayout constraints (because constraints dictate the locations, not manually set frame properties … the frame properties will be reset as constraints are reapplied). See this loosely related post in which it is demonstrated how to properly adjust a constraint to move a view. (In that case, we’re animating, which is not the issue here, but it does demonstrate how how one adjusts a constraint to effect the movement of a UIView.)

    In short, if you want to move a UIView within autolayout, you must not try to change the frame, but rather adjust the constraints themselves. This is simplified if you create IBOutlet references for the constraints themselves, at which point, you can adjust the constant of the NSLayoutConstraint.


    Update:

    Egor recommended enumerating the constraints and editing the one that matched the one in question. That works great, but personally, I prefer to have an IBOutlet for the specific constraint I want to edit rather than enumerating them and hunting the one in question. If you had an IBOutlet called indentViewWidthConstraint for the width NSLayoutConstraint of the indentView, you could then simply:

    self.indentViewWidthConstraint.constant = newIndentConstantValue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar to this question I have a custom subclass of UITableViewCell that has a
I have a custom UITableViewCell subclass. I have set the contentView of my cell
I have a custom subclass of NSSearchField that I would like to set the
I have a UITableViewCell subclass with backgroundView set to my own UIView object. This
First of all, this discussion did not solve my problem. Custom UITableViewCell subclass: This
I have a UITableView with custom Cell (subclass of UITableViewCell). Each cell view has
I have a custom UITableViewCell subclass, and a table view controller which I want
I have a custom view class which is a subclass of UITableViewCell. I have
I have created a custom subclass of UITableViewCell. There, I allow the user to
I have a UISwitch inside a custom UITableViewCell (the subclass of which I call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.