iphone - Set frame to UIview which is child view of UIScrollview -
i have created 1 uiview
inside uiscrollview
storyboard, above uiview
more views present label, imageview etc inside uiscrollview
.
i want set frame uiview programatically. have tried set frame using setframe function programatically, not working uiview
inside uiscrollview
.
i have seen similar questions this, everywhere create uiview programmatically, want use uiview
created in storyboard , want set frame that.
can please suggest me, how can this?
thanks.
edit1: added code
[myownview setframe:cgrectmake(0, 50, 320, 110)];
myownview uiview added inside uiscrollview, write above code inside viewdidload method.
edit2:
nsstring usertext = @"some long text multiple lines"; cgsize constraint = cgsizemake(200, 90000.0f); // size of text given cgsize made constraint cgsize size = [usertext sizewithfont:[uifont fontwithname:@"helveticaneue" size:13] constrainedtosize:constraint linebreakmode:nslinebreakbywordwrapping]; uilabel *mylabel = [[uilabel alloc] initwithframe:cgrectmake(20,20, size.width, size.height)]; [mylabel setlinebreakmode:nslinebreakbywordwrapping]; [mylabel setnumberoflines:0]; mylabel.font = [uifont fontwithname:@"helveticaneue" size:13]; [myscrollview addsubview:mylabel]; [myownview setframe:cgrectmake(0, mylabel.frame.origin.y+mylabel.frame.size.height+10, 320, 110)];
i have create iboutlets properly.
myscrollview frame (0, 135, 320, 298) on storyborad myownview frame (0, 214, 320, 110) on storyborad inside myscrollview
i have set contentsize myscrollview below
myscrollview.contentsize = cgsizemake(320, 600);
now want change origin of myownview.
most impornatant condition autolayout "true".
make outlet of view storyboard respective class.
refer created view like: here no need allocate again.just change frame.
[self.newview setframe:cgrectmake(0, 70, 320, 80)];
if setting frame leads out of scrollview,then unable see view.
view visible in scrollview area.
Comments
Post a Comment