Using an interface constructor to layout a scrollable view with images and text

I have a requirement in my application to display a bunch of information, which includes both text and images. It will be quite long, so it will need to be scrolled to access all the content.

I know that I can achieve this by programmatically adding various UILabels, UIImages, etc. in a UIScrollView. But this is a proof of concept, so I'm looking for something a little faster than the need to work out all the positioning and the required code. Information in any case is static and does not require interaction with the code.

Is there a way to do this using an interface constructor (storyboard or xib ok)?

+3
source share
4 answers

you can definitely do this if you just want a quick interface

1.> you may need to find out how long your scroll view has been viewed, for example, in my case, I set it to 1568

enter image description here

2.> Then I drag all the controls that will correspond to the first representation of 568 pixels, in the form of a scroll and arrange them.

3.> Then change the Y value for this type of scroll to about 500 so that you can see the rest of the scroll and put everything you need there.

enter image description here

4.> After you have all the controls and do not forget to set the frame to 0,0,320,568

enter image description here

5.> last step, in your code, set SCROLLVIEW.contentSize = CGSizeMake (320, 1568);

, , , .

+6
  • , xib ViewController.

  • UIView, , , .

  • xib/ UIScrollView VC. , , scrollview, .

()!

, , . , scrollview " ", contentSize.

, , :

UIScrollView.

:

@implementation UIScrollView (MyHandyCategory)

-(void)awakeFromNib {

   NSArray *subViews = [self subviews];
   UIView *contentView = [subViews objectAtIndex:0];
   [self setContentSize:contentView.frame.size];

}

@end

( )! , , ContentSize . , , Builder!

+2

Id WebView HTML-, . Easy-Peasy.

0
source

I would suggest a UICollectionView. It is pretty simple. There is a good tutorial here:

http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12

0
source

All Articles