Note that there are some explanatory texts on larger screens.

plurals
  1. POUIView setCenter problem
    primarykey
    data
    text
    <p>I'm having a lot of trouble doing something very simple. I have a viewController and a subViewController, both with views loaded from nibs. For clarification the parent view is sized 1024 by 748 and the subView is 640 by 480 in the nibs. </p> <p>On the viewController's viewDidLoad I add the subViewController's view like so:</p> <pre><code>[self.view addSubview:self.subViewController.view]; NSLog(@"subview.frame:%@",NSStringFromCGRect(self.subViewController.view.frame)); </code></pre> <p>The log outputs:</p> <pre><code>subview.frame:{{0, 0}, {640, 480}} </code></pre> <p>Then, just to test things out, I use setCenter to attempt to reposition the subview within the parent view at the same position like so:</p> <pre><code>CGPoint newCenter = CGPointMake(0,0); //should stay at the same position.. [self.subViewController.view setCenter:newCenter]; NSLog(@"after changing center.subview.frame:%@",NSStringFromCGRect(self.subViewController.view.frame)); </code></pre> <p>The log outputs:</p> <pre><code>after changing center. subview.frame:{{-320, -240}, {640, 480}} </code></pre> <p>Now I have a feeling that something might be getting screwed up in the nibs and am guessing it's something to do with the springs &amp; struts / size &amp; position options. I can only guess it's this because this is the feature I have least understanding of when it comes to IB. </p> <p>Any other ideas as to what could be causing this issue? Do you guys have any tips in general on how to set up viewcontrollers' views in IB so that they are automatically positioned in alignment with other viewcontrollers' views? And after setting things up, is setCenter the correct way of moving them around dynamically?</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.
    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