ios - Autolayout table cell with image and text fields? -
i'm looking table view cell photo , wrapping text auto layout. i've managed lot auto layout, i'm @ loss on how one.
┌─────────────────────────────────────────────────────┐ │ ┌──────────┐ ┌────────────────────────────────────┐ │ │ │ │ │ title (might wrap) │ │ │ │ │ └────────────────────────────────────┘ │ │ │ photo │ ┌────────────────────────────────────┐ │ │ │ │ │ body text. may wrap, may contain │ │ │ │ │ │ multiple lines. │ │ │ │ │ └────────────────────────────────────┘ │ │ └──────────┘ │ └─────────────────────────────────────────────────────┘
as text expands, want keep photo in top left , expand cell. however, cell should never shrink below minimum required show photo (with margins).
┌─────────────────────────────────────────────────────┐ │ ┌──────────┐ ┌────────────────────────────────────┐ │ │ │ │ │ title (might wrap) │ │ │ │ │ │ maybe 2 lines. │ │ │ │ photo │ └────────────────────────────────────┘ │ │ │ │ ┌────────────────────────────────────┐ │ │ │ │ │ body text. may wrap, may contain │ │ │ │ │ │ multiple lines. │ │ │ └──────────┘ │ │ │ │ │ text require more vertical │ │ │ │ space photo. │ │ │ └────────────────────────────────────┘ │ └─────────────────────────────────────────────────────┘
i'm requiring ios 8 or later.
i've tried doing 3 views listed, , putting left item , right items in 2 views. every combination try seems ignore photo's minimum size.
(btw, curious: graphic via monodraw.)
try having following relationships:
photo:
- width = x
- height = y
- left = cell + z
- top = cell + z
title:
- left = photo + z
- right = cell - z
- top = cell + z
the label auto calculate height based on content
body:
- left = title
- right = title
- top = title.bottom + z
cell: (this important part)
- bottom >= (equal or greater than) body.bottom + z
- bottom >= photo.bottom + z
this force cell be, @ times, either taller image + offset or taller label + offset
Comments
Post a Comment