views:

249

answers:

1

I understand modal views cover the entire screen. But I really want a view that covers only half the screen just like the keyboard. So, please tell me why this doesn't work

MyController *controller = [[MyController alloc] initWithNibName:@"MyView" bundle:nil];
CGRect frame = CGRectMake(0,44,768,264);
[controller view].frame = frame;
contoller.delegate = self;
[[self view] addSubView:[controller view]];
[controller release];

I am trying to add a sub view to my current view and make it appear where the keyboard appears.

It throws a BAD ACCESS exception

A: 

In my code (above), I was using a custom UIViewController with it's own view [set to UIView on IB]. I couldn't get it to work by setting frame for the view controller's view.

So I added a custom UIView without a Nib file with all the controls (buttons, textfields) added on initWithFrame.

MyCustomView = [[MyCustomView] alloc] initWithFrame:frame delegate:self];
[self.view addSubView:MyCustomView];

Thanks for your comment, Jacob.

Dave