views:

1182

answers:

1

I need to display a UIView/UIViewController when the user taps a button and the modal view should appear just like how the key board appears from the bottom bar when you edit text in a UITextField. Using the following code, I get to show it as a pop up.

[self presentModalViewController:child animated:YES];

How to make it appear like the keyboard?


I understad modal views cover the entire screen. But I really want a view that covers only half the screen. 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.

+1  A: 

Check if your child.modalTransitionStyle == UIModalTransitionStyleCoverVertical.

(And a model view controller always cover the whole screen. If you just need to cover half of the screen like the keyboard, you need to put the view controller's view as a subview of the main view, then animate it in manually with animation blocks.)

KennyTM
that helps. thank you. can you please elaborate on the animations for sliding from the bottom bar?
Dave
@Dave: Just set the transition style and present the modal view controller.
KennyTM
ok. I set the transitionstyle to CoverVertical and changed PresentationStyle from FormSheet to PageSheet. It is animating just like how I wanted but it covers the whole page. Is there a way to resize the view?
Dave
@Dave: A modal view controller always cover the whole page.
KennyTM
well then I guess I need to add a sub view, in that case, right? Please see my updated question [above].
Dave
@Dave: Adding a view controller *not* as subview of a window or view controller can cause problems. Can you *not* use a view controller?
KennyTM
you are right, Kenny. http://stackoverflow.com/questions/2450594/uiview-transition-and-animation
Dave