Re: UIView, UILabel, and sizeToFit
Re: UIView, UILabel, and sizeToFit
- Subject: Re: UIView, UILabel, and sizeToFit
- From: Matt James <email@hidden>
- Date: Wed, 28 Apr 2010 20:55:39 -0400
On Apr 28, 2010, at 12:50 PM, Fritz Anderson wrote:
> On 27 Apr 2010, at 8:56 PM, Matt James wrote:
>
>> Unfortunately, NSLog-ing the values of label.frame.size.width and
>> containerView.frame.size.width shows that the values are "0".
>
> Show us your code, particularly all the lines that call NSLog. The first thing I'm looking to see is whether you're trying to print the width with %d or %i.
>
> — F
Hi Fritz,
Thanks for the reply. I've included the code below. I was originally testing only the widths of those views which was coming out zero. In the code below, however, I changed it to output both the widths and heights. Of interest, the heights are coming out abnormally large and the widths are still zero.
To give you some background, the container view that uses this code is used as an item view in my own implementation of an NSCollectionView (since that class is not available on the iPhone or iPad.
- (void)setRepresentedObject:(NSString *)aString
{
name.text = aString;
[name sizeToFit];
[self sizeToFit];
NSLog(@"Container size: %d, %d", self.frame.size.width, self.frame.size.height);
NSLog(@"UILabel size: %d, %d", name.frame.size.width, name.frame.size.height);
}
I tried the code with both %d and %i - the results seem to be the same.
Thanks for any help you can provide!
-Matt_______________________________________________
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