Note that there are some explanatory texts on larger screens.

plurals
  1. POSet frame to UIview which is child view of UIScrollview
    primarykey
    data
    text
    <p>I have created one <code>UIView</code> inside the <code>UIScrollView</code> from storyboard, Above <code>UIView</code> some more views will be present like label, imageview etc inside <code>UIScrollView</code>. </p> <p>I want to set the frame to UIView programatically. I have tried to set frame using <strong>setFrame</strong> function programatically, but its not working for the <code>UIView</code> which is inside <code>UIScrollView</code>.</p> <p>I have seen similar questions like this, but everywhere create the UIView programmatically, but I want to use the <code>UIView</code> created in storyboard and want to set the frame to that.</p> <p>Can anybody please suggest me, how can i do this?</p> <p>Thanks.</p> <p>Edit1: Added the code</p> <pre><code>[myownview setFrame:CGRectMake(0, 50, 320, 110)]; </code></pre> <p>myownview is UIView added inside UIScrollView, write above code inside viewDidLoad method.</p> <p>Edit2:</p> <pre><code> NSString userText = @"Some long text which is multiple lines"; CGSize constraint = CGSizeMake(200, 90000.0f); // Get the size of the text given the CGSize we just made as a 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)]; </code></pre> <p>I have create the IBOutlets properly.</p> <pre><code>myscrollview frame is (0, 135, 320, 298) on storyborad myownview frame is (0, 214, 320, 110) on storyborad inside myscrollview </code></pre> <p>I have set the contentsize to myscrollview as below</p> <pre><code>myscrollView.contentSize = CGSizeMake(320, 600); </code></pre> <p>now want to change the origin of myownview.</p> <p>Most impornatant condition is Autolayout is <b>"TRUE"</b>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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