ios - Show view from xib in ScrollView -


firstly want newbie @ ios development. have problem showing view xib file in scrollview.

this myview green background 1 label. here code controller:

@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 

and here code main controller scrollview:

 - (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]; 

}

only thing want want see myview (green background 1 label) inside scrollview. if run app, scrollview empty, nothing shown inside.

probably stupid question said, newbie @ this. have pagecontroll app apple me quite complicated code in ios beginning. of course googling... please tell me problem. thank you

where define scroll? property of viewcontroller? think problem here don't add scroll view viewcontroller's view with

[self.view addsubview:scroll] 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -