• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[RESOLVED] Re: What's wrong with this code, why is the label invisible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RESOLVED] Re: What's wrong with this code, why is the label invisible?


  • Subject: [RESOLVED] Re: What's wrong with this code, why is the label invisible?
  • From: Aaron Lewis <email@hidden>
  • Date: Tue, 24 Feb 2015 20:06:40 +0800

Thanks Roland.

I never know about the contentView and intrinsicContentSize property,
learned something new today.
You enlightened me a lot.

So I tried to use interface editor before but got the same result. Now
I see why. I didn't set a minimal height for the label:

@"V:|-0-[imageView]-0-[label(>=30)]-0-|"

Changing the constraints to something like this worked.


On Tue, Feb 24, 2015 at 6:01 PM, Roland King <email@hidden> wrote:
>
>> On 24 Feb 2015, at 16:44, Aaron Lewis <email@hidden> wrote:
>>
>> Can someone please take a look at this?
>>
>> http://stackoverflow.com/questions/28690947/why-is-this-uiimage-and-uilabel-collapsed
>>
>> In short words, the UILabel is invisible when I use a image in the UIImageView.
>> It works if I only set backgroundColor.
>>
>> I already add a constraint on it .. I couldn't really tell why.
>>
>> —
>
> 1) don’t add to the cell, add to the cell’s contentView (see the documentation on UITableViewCell)
> 2) your vertical layout is ambiguous, almost always the case when something ‘disappears’. The label has an intrinsicContentSize, the image has one too because you have an image set into it. They both have the same default 750 content compression resistance. The cell is a fixed height (unless you’re using auto-height cells in which case this shouldn’t be happening) so one or other of them loses out. In your case the label loses out and its height goes to zero (you could see all this in the debugger by the way).
>
> If you drop the content compression resistance in the vertical direction of the uiimage from 750 to 749, or less, then the label should get its height and the image view should get what’s left.
>
> And the comment on StackOverflow that you are setting up the views every time you dequeue the cell is accurate.
>
> And you could use Interface Builder for this too which is usually easier.



--
Best Regards,
Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
Finger Print:   9F67 391B B770 8FF6 99DC  D92D 87F6 2602 1371 4D33

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: [RESOLVED] What's wrong with this code, why is the label invisible?
      • From: Roland King <email@hidden>
  • Prev by Date: Convert CGFloat to NSNumber
  • Next by Date: Re: Displaying multiple errors in NSOpenPanel beginSheetModalForWindow:completionHandler:
  • Previous by thread: Re: Convert CGFloat to NSNumber
  • Next by thread: Re: [RESOLVED] What's wrong with this code, why is the label invisible?
  • Index(es):
    • Date
    • Thread