Reputation: 2702
In the interface builder, I'm trying to create a prototype cell with an image that covers the entire cell but it is not running how it is expected.
As you can see in the following screenshot of my interface builder, I have an image view covering the entire cell, and is constrained to each edge of the cell:
And in fact this is how I expect it to look on the simulator, but instead I get this:
Where as you can see, it is not anchored all the way to the sides, and it may be hard to see, but the image actually extends past the bottom of the cell (if you look hard enough you can see the separator striking through the bottom portion of the image.
This is really buggy and I really have no idea what's happening.
Upvotes: 5
Views: 2597
Reputation: 5130
This is because you are setting constraint to margins.
When adding constraints to uiimageview
. Uncheck constraint to margin.
Upvotes: 0
Reputation: 931
Upvotes: 0
Reputation: 130
I think you accidentally disabled cell's Clip Subviews
in code or in Storyboard, by default It should be enabled.
If it's not the cell, check it's Content View
.
By the way, by disabling Clip Subviews
for both Cell and it's Content view, I managed to reproduce your bug.
Upvotes: 1
Reputation: 7736
Perhaps adding aUIImageView
inside of your cell in code.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//configure cell
let imageView = UIImageView(frame: self.cell.frame)
imageView.image = YOUR_IMAGE
imageView.center = cell.center
imageView.frame.size = cell.frame.size
imageView.contentMode = .ScaleAspectFill
cell.addSubview(imageView)
}
Hope this helps.
Upvotes: 1