0

I have a problem with constraints. First of all i want to highlight that this is working on my iPhone 5, but not on iPhone 4.

App crashes on start. This is an error:

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x16da56d0 V:[UIImageView:0x16da55f0(55)]>",
    "<NSLayoutConstraint:0x16da63f0 V:[UIImageView:0x16da55f0]-(18)-[UIImageView:0x16da5860]>",
    "<NSLayoutConstraint:0x16da6450 V:[UIImageView:0x16da5860]-(8)-|   (Names: '|':UITableViewCellContentView:0x16da5000 )>",
    "<NSLayoutConstraint:0x16da6570 V:|-(15)-[UIImageView:0x16da55f0]   (Names: '|':UITableViewCellContentView:0x16da5000 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x16db2040 h=--& v=--& V:[UITableViewCellContentView:0x16da5000(44)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x16da56d0 V:[UIImageView:0x16da55f0(55)]>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

Clearly problem with my UI elements -> constraints, but now the funniest part. This is the last executed line of code:

 player = [[AVAudioPlayer alloc]
      initWithContentsOfURL:[NSURL fileURLWithPath:resPath]
                      error:&error];

How this is connected to UI constraints... That is the question...

Obviously I tried to remove all of my constraints in my ViewController, but it changes nothing.

Could somebody explain it to me?

EDIT:

My elements in ViewController looks like this:

enter image description here

EDIT 2:

ListAdapter:

- (UITableViewCell *)getCell:(UITableView *)tableView
               withIndexPath:(NSInteger)index {

  _tableView = tableView;
  static NSString *CellIdentifier = @"Cell";
  UITableViewCell *cell =
      [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                  reuseIdentifier:CellIdentifier];
  }
  id<ISong> song = [_data objectAtIndex:index];

  UIImageView *recipeImageView = (UIImageView *)[cell viewWithTag:1];
  UIImageView *lockImageView = (UIImageView *)[cell viewWithTag:3];
  recipeImageView.image = [UIImage imageNamed:[song boxId]];

  UILabel *recipeNameLabel = (UILabel *)[cell viewWithTag:2];
  recipeNameLabel.text = [song songName];

  if (![Settings isPremium]) {
    lockImageView.hidden = [song unlock];
  } else {
    lockImageView.hidden = YES;
  }

  [Config setPlayerControllerStyle:recipeImageView main:nil];
  cell.translatesAutoresizingMaskIntoConstraints = NO;
  return cell;
}
Lau
  • 1,804
  • 1
  • 23
  • 49
  • 1
    It's is not a iPhone 4 thing but a iOS 7 vs 8 issue. – rckoenes Sep 01 '15 at 09:52
  • This is most likely an issue with the height you define for the table view cell. What are you returning. On iOS7 you have to calculate the height and return it in `heightForRowAtIndexPath`. On iPhone 4 I imagine this is not big enough and the constraints for height are bigger than the cell height. Also seems you do not fully specify the constraints. Make sure you have specified all the layout. Seeing `NSAutoresizingMaskLayoutConstraint` implies that xcode has had to generate some constraints for you. Looks like the height of the second image is not defined by you and it has put 44. – Rory McKinnel Sep 01 '15 at 11:45
  • Can you show your delegate code for `heightForRowAtIndexPath`. – Rory McKinnel Sep 01 '15 at 12:01

1 Answers1

0

NSAutoresizingMaskLayoutConstraint is a set of constraints that have been translated from an auto resizing mask.

To stop these from being created you need to add the code...

someView.translatesAutoresizingMaskIntoConstraints = NO;

This will stop these being created. It looks like they are part of a UITableViewCell but you haven't shown enough code to work out exactly where it's happening :D

Fogmeister
  • 76,236
  • 42
  • 207
  • 306
  • changing that bool value on my tableView didn't help. Witch information do you need? – Lau Sep 01 '15 at 09:58
  • Fogmeister is probably right. This issue appears to be with a UITableViewCell of some kind or something in it. The error message references UITableViewCellContentView. – Cliff Ribaudo Sep 01 '15 at 10:23
  • @Lau Have you put a textfield or something in the tableviewcell? Maybe this is the cause. Without seeing the code that creates the cell it's hard to see anything. – Fogmeister Sep 01 '15 at 10:35
  • Yes, I have few elements inside my cell - I put code of my adapter in main post. – Lau Sep 01 '15 at 11:30