Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After a lot of trial and error I found a solution based on an approach explained in the following <a href="https://stackoverflow.com/questions/1726250">question</a>, answered by <a href="https://stackoverflow.com/users/23324/brian-webster">Brian Webster</a>. </p> <p>The solution was originally suggested for a Cocoa environment. I hope it is valid in an iOS environment as well. </p> <ol> <li>Create the main view controller with a NIB-file. In the NIB, the File's Owner should correspond to the class of your main view controller.</li> <li>Create a custom view controller with a NIB-file. In this NIB, the File's Owner should correspond to the class of your custom view controller.</li> <li>Create a custom view controller property in your main view controller class.</li> <li>Create an UIView property in the main view controller class. It will hold your custom view controller's view. Define it as an IBOutlet, so it can be linked in the NIB.</li> <li>Drop a UIView in your main view controller's NIB. Link it to the main view controller's view IBOutlet. It will be used as a placeholder for the custom view. </li> <li>In the main view controller's viewDidLoad method, load the custom view controllers NIB, determine the custom view's frame size and copy the view in the main view controller's view. </li> </ol> <p>Here is some code:</p> <ul> <li><p>MainViewController.h <pre><code>@interface MainViewController : UIViewController { CustomViewController *customViewController; UIView *customView; } @property (nonatomic, retain) CustomViewController *customViewController; @property (nonatomic, retain) IBOutlet UIView *customView; @end</pre></code></p></li> <li><p>MainViewController.m <pre><code>- (void)viewDidLoad { CustomViewController *controller = [[CustomViewController alloc] initWithNibName:@"CustomViewController" bundle:nil]; self.customViewController = controller; [controller release]; customViewController.view.frame = customView.frame; customViewController.view.autoresizingMask = customView.autoresizingMask; [customView removeFromSuperview]; [self.view addSubview:customViewController.view]; self.customView = customViewController.view; [super viewDidLoad]; } </pre></code></p></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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