I’m trying to create a news viewer with Xcode 4. This should look like the following:
=============================== Title comes here ------- Date Image News Body ================================
As you can see, the news body must be pushed downward depending on the size of the image. The image must be pushed downward as the height of the title varies. I know I have to do some programming to position them dynamically. The only problem is I’m not familiar with CGRect and Frame things…
Where can I find a tutorial or sample code I can take a look and get some ideas? Practical codes or tutorials would be appreciated as just reading documentation doesn’t really give me a clear idea how to approach this.
UILabelprovides-sizeWithFont:constrainedToSize:lineBreakMode:which will allow you to determine the size needed to fit the text you wish to display. I put together an example of resizing UILabels when I first ran into a similar problem and posted it here: http://blog.carbonfive.com/2009/07/10/resizing-uilabel-to-fit-text/I’m afraid that’s rather old now but I think should still be of some use.