Dynamic UILabel positions using interface builder?

I'm trying to make a dynamic view with multiple numbers of UIlabels (and possibly image) However, I'm having troubles with positioning them dynamically. The following is what it should look like...

Date (UILabel) Title (UILabel) Image (UIImage) Body Text (UILabel)

You can see that the height of image and the length of the body text can vary. If the image is huge, it must push the body text downward so that they don't get overlapped each other...

Is it possible to be done using only Interface Builder? If not, how can I programmatically do it? - by manually calculating each UI's height? Some sample codes would be great.... Thank you.

Answers


You can't its only available for MacOS at the moment. You will have to do it in code.

I'm using such category:

@interface UILabel (UDSize)

- (void)sizeHeightToFitText;

@end

@implementation UILabel (UDSize)

- (void)sizeHeightToFitText {
    [self setLineBreakMode:UILineBreakModeWordWrap];
    [self setNumberOfLines:0];

    CGSize expectedSize = [[self text] sizeWithFont: self.font
                                  constrainedToSize: CGSizeMake(self.frame.size.width, CGFLOAT_MAX)
                                      lineBreakMode: self.lineBreakMode];

    CGRect newFrame = self.frame;
    newFrame.size.height = expectedSize.height;
    [self setFrame: newFrame];
}

@end

Need Your Help

My Windows 8 app doesn't appear in other stores

windows-8 windows-store-apps windows-store

I developed a windows 8 game, and I can't find it on the other Stores.

How can I kill all sessions connecting to my oracle database?

oracle session sqlplus kill database-administration

I need an sqlplus script to quickly kill off all external sessions connecting to my oracle database without the supervision of and administrator.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.