tags:

views:

19

answers:

2

Hi,

I'm beginner with iPhone and want to know how to add a view in a window based application.

I crate the application, then I added the ViewControler+XIB to my project. I include the .h file in both AppDelegate-Files.

Then I create a object of the View "StartViewController" with

StartViewController *startView;

and add the property in the AppDelegate.h file:

@property (nonatomic, retain) StartViewController *startView;

In the AppDelegate.m I add:

@synthessize startViewController

and in the application method:

[window addSubview:startViewController.view];

But it doesn't appear when I start the application, what I forgot?

+1  A: 

You're not allocating or initializing it anywhere that I can see. From what you're saying, it seems like you need to put in a

startView = [[StartViewController alloc] initWithNibName:@"xib filename without dot xib" bundle:nil];

If this doesn't sound right, it may instead be that you aren't setting Interface Builder up right. How is the main window linking to this XIB / view controller of yours? Do you have it referenced as a view?

Kalle
Found it, thank you.
Kovu
A: 

hi Kovu,

Just connect the view with interface builder by dragging.

and still if you can't connect , here is link where a number of applications are provided to learn iPhone applications.

iPhone Fun