title: Loading a view into a UIScrollView AND getting the content inside to work
body: <p>I have a tab based application I am working on.</p>
  
  <p>I have a view controller named DetailsView.m, with an accompanying nib file called DetailsView.xib. This has a couple of UILabels in, which are linked using IBOutlet to DetailsView.m view controller. When I load this view controller/view using the tab bar controller, it works fine and the UILabels are populated dynamically.</p>
  
  <p>Now I want to load this entire view inside a UIScrollView instead so I can fit more content in.</p>
  
  <p>So I created another view controller called DetailsHolder.m with a nib file called DetailsHolder.xib, and assigned this to the tab bar controller.</p>
  
  <p>I wrote this code below to load the first view (DetailsView) into the UIScrollView in the second view (DetailsHolder). I wrote it in the viewDidLoad method of DetailsHolder:</p>
  
  <pre><code>DetailsView* detailsView = [[DetailsView alloc] initWithNibName:@"DetailsView" bundle: nil];
  CGRect rect = detailsView.view.frame;
  CGSize size = rect.size;
  [scrollView addSubview: detailsView.view];    
  scrollView.contentSize = CGSizeMake(320, size.height);
  </code></pre>
  
  <p>This correctly loads the sub view into the UIScrollView, however, the labels inside DetailsView no longer do anything. When I put an NSLog inside viewDidLoad of DetailsView - it never logs anything. It's as if I've loaded the nib ok, but its no longer associated with the view controller anymore. What am I missing here? I'm a bit of a newbie in obj C/iOS (but have many years Actionscript/Javascript knowledge.</p>
  
  <p>Thanks in advance, </p>
  
  <p>Rich</p>
  
  <p>Edit: Contents of DetailsView as requested:</p>
  
  <p>DetailsView.h:</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "AppModel.h"
  
  @interface DetailsView : UIViewController {
      IBOutlet UITextView* textView;
      IBOutlet UIImageView* imageView;
  }
  
  @end
  </code></pre>
  
  <p>DetailsView.m</p>
  
  <pre><code>#import "DetailsView.h"
  
  @implementation DetailsView
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
          // Custom initialization
      }
      return self;
  }
  
  - (void)dealloc
  {
      [super dealloc];
  }
  
  - (void)didReceiveMemoryWarning
  {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Release any cached data, images, etc that aren't in use.
  }
  
  #pragma mark - View lifecycle
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view from its nib.
  }
  
  - (void)viewWillAppear:(BOOL)animated
  {
      AppModel* model = [AppModel sharedInstance];
  
      [model loadData];
  
      int selectedLocation = [model getSelectedLocation];
      NSArray *locations = [model getLocations];
      NSArray *data = [locations objectAtIndex:selectedLocation];
  
      textView.text = [data objectAtIndex: 0];
  
  
      UIImage *theImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[data objectAtIndex: 4] ofType:@"jpg"]];
  
      imageView.image = theImage;
  
  }
  
  - (void)viewDidUnload
  {
      [super viewDidUnload];
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
  }
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  {
      // Return YES for supported orientations
      return (interfaceOrientation == UIInterfaceOrientationPortrait);
  }
  
  @end
  </code></pre>
  
  <p>Essentially all its doing is grabbing selectedLocation (int) from a singleton (which is my model), then grabbing an array from the model, and then trying to insert an image and some text into my view. In my nib file, i have a UIImageView and a UITextView, which I have linked to the two IBOutlets declared in DetailsView.h</p>