Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tjh21cen

macrumors newbie
Original poster
Jan 6, 2009
3
0
Hi Im really new at iphone development, just trying to get a basic program with some view controllers going. Im having an issue with an error:

- (void)viewDidLoad {
IntroViewController *introController = [[IntroViewController alloc]
initWithNibName:mad:"IntroView" bundle:nil];
self.introViewController = introController;
[self.view insertSubview:introController.view];
error shows up here as follows:
warning: 'UIView' may not respond to '-insertSubview:'

[introController release];
}

I am simply trying to add my view with a loaded nib to the main view. Is view did load the best place for this? Any help, tips, etc are greatly appreciated. I can post more code if the problem cant be discovered with just this code.

Also, how do you add code like I have seen in this forum? Thanks everybody
 
Check the class reference for UIView. insertSubview: requires another parameter. That is, you must use insertSubview:aboveSubview:, insertSubview:atIndex:, or insertSubview:belowSubview. You could also look into using addSubview: and see if that suits your needs instead.

Also, how do you add code like I have seen in this forum? Thanks everybody
Use the [ CODE ] / [ /CODE ] tags. See the
code.gif
icon in the toolbar.
 
You could also look into using addSubview:

What he said. I do a lot of view manipulation in viewDidLoad and I just find it quite simple to use addSubView:.

Also, your example looks a bit strange to me. You are in the 'ViewDidLoad' of one view controller, where you then load another viewcontroller from a nib file and then manipulate that second viewcontrollers view. I would have expected that if you wanted to manipulate that second view that you would have just put the code in the 'ViewDidLoad' method of that second view controller and just do

[self.view addSubview:myView];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.