Note that there are some explanatory texts on larger screens.

plurals
  1. POShow view from xib in ScrollView
    text
    copied!<p>firstly I want to say that I am newbie at iOS development. I have a problem with showing a view from xib file in ScrollView.</p> <p>This MyView is only green background with one label. Here is a code from its controller:</p> <pre><code>@implementation MyView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { //init code } return self; } - (id) initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; } return self; } @end </code></pre> <p>And here is a code from main controller where is the ScrollView:</p> <pre><code> - (void)viewDidLoad { [super viewDidLoad]; scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 67, self.view.frame.size.width, self.view.frame.size.height)]; scroll.pagingEnabled = YES; scroll.frame = CGRectMake(0, 20, 320, 350); scroll.contentSize = CGSizeMake(320, 350); scroll.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; scroll.bounces = YES; scroll.bouncesZoom = YES; scroll.scrollEnabled = YES; scroll.minimumZoomScale = 0.5; scroll.maximumZoomScale = 5.0; scroll.delegate = self; scroll.pagingEnabled = YES; NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil]; UIView *myView = [nibContents objectAtIndex:0]; myView.frame = CGRectMake(0,20,300,300); [scroll addSubview:myView]; </code></pre> <p>}</p> <p>Only thing I want to do is that I want to see MyView (green background with one label) inside the ScrollView. If I run this app, scrollview is empty, nothing is shown inside. </p> <p>Probably it is a stupid question but as I said, I am newbie at this. I have a PageControll app from Apple but for me this is quite complicated code in my iOS beginning. Of course I was googling... Please tell me where is a problem. Thank you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload