0

I'm trying to change the Vertical Space constraint of a View that contains a button and a progress bar. The following picture shows the constraint:

enter image description here

The button is aligned both horizontal and vertically within the view:

enter image description here

It is referenced as an IBOutlet and changed programmatically in viewDidLoad in this way:

// Constraing originally set to 15.0 in Interface Builder
if (isiPhone5) {
    [SSLayoutConstraintButtonVSpace setConstant:0.0f];
} else {
    [SSLayoutConstraintButtonVSpace setConstant:15.0f];
}

Once I run the app with an iPhone 5, the change is done well and apparently it seems to work. However, if I click on the button, id does not respond as it should. It seems that the button click area still remains in the original position before setting the new constraint.

Does anybody know what is going on there?

GoRoS
  • 5,183
  • 2
  • 43
  • 66
  • Tried to add `[SSBtnConnec layoutIfNeeded]; [SSContainerButton layoutIfNeeded];` without success. – GoRoS Aug 06 '14 at 06:37

1 Answers1

0

John Griffith from the Apple developer forum gave me the hint of what could be wrong in my view hierarchy, and he was absolutely right.

My Table View Cell was cropping the button when it was moved by the constraint. Changing it's background color confirmed it straightaway.

So, keeping the conditional constraint and resizing the Table View Cell int the following way solved the problem:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (isiPhone5) {
        return 500.0f;
    } else {
        return 460.0f;
    }
}
GoRoS
  • 5,183
  • 2
  • 43
  • 66
  • GoRoS, which Apple Developer Forum are you asking Autolayout questions in? I've been unable to determine which one is the right one. Thx. – Gallymon Sep 23 '14 at 02:06
  • What do you need that for? Here is the whole question and the right answer. Anyway, the forum in particular is the Apple's official one for iOS: https://devforums.apple.com/community/ios – GoRoS Sep 23 '14 at 06:37
  • GoRoS, my problem's related, perhaps, but different: http://stackoverflow.com/questions/25987244/autolayout-problems-with-ios8-with-code-that-works-fine-on-ios7 – Gallymon Sep 23 '14 at 06:58