Hi, I want to put an image view on the left of a table view in landscape and above it in portrait.
So I have to do this in code. now... for landscape I have this constraint added
As you can see from the string format...
- the left edge and the image view is the default space of 20,
- the image view has a width that I don't care about,
- the image view should resize
- there should be 20 pixels between the image view and table view
- the table view should be 280 wide
- and there should be a default space of 20 between the table view and the right edge.
now... this doesn't work. The image view resizes fine, but it complains about conflicting constraints.
It seems to think that the image view HAS to be a particular size.
Even if I set the hugging and compression resistance of the image view to be less than the table view it still has this issue.
it complains and says it has to break the -(20)- between the image and the table view (which doesn't make sense because it resizes the image view)
I can change the spacing between views and edges to an inequality and it won't complain (but wont show up right)
I can give the image view an explicit size and let the table view not have an explicit size and it won't complain.
does anyone know what I might be doing wrong? Do I need to give more info for this to make sense?
So I have to do this in code. now... for landscape I have this constraint added
Code:
[NSLayoutConstraint constraintsWithVisualFormat:@"|-[imageView]-(20)-[tableView(280)]-|"
options:NSLayoutFormatAlignAllTop
metrics:nil
views:views];
- the left edge and the image view is the default space of 20,
- the image view has a width that I don't care about,
- the image view should resize
- there should be 20 pixels between the image view and table view
- the table view should be 280 wide
- and there should be a default space of 20 between the table view and the right edge.
now... this doesn't work. The image view resizes fine, but it complains about conflicting constraints.
It seems to think that the image view HAS to be a particular size.
Even if I set the hugging and compression resistance of the image view to be less than the table view it still has this issue.
it complains and says it has to break the -(20)- between the image and the table view (which doesn't make sense because it resizes the image view)
I can change the spacing between views and edges to an inequality and it won't complain (but wont show up right)
I can give the image view an explicit size and let the table view not have an explicit size and it won't complain.
does anyone know what I might be doing wrong? Do I need to give more info for this to make sense?