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.

2 Answers 2

1

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.)

7
  • that helps. thank you. can you please elaborate on the animations for sliding from the bottom bar?
    – Dave
    Commented Mar 12, 2010 at 6:40
  • @Dave: Just set the transition style and present the modal view controller.
    – kennytm
    Commented Mar 12, 2010 at 9:04
  • 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
    Commented Mar 12, 2010 at 22:40
  • @Dave: A modal view controller always cover the whole page.
    – kennytm
    Commented Mar 13, 2010 at 5:30
  • well then I guess I need to add a sub view, in that case, right? Please see my updated question [above].
    – Dave
    Commented Mar 15, 2010 at 20:59
0

I know its an old question, but an answer to this is to use a UIActionSheet.

It won't present a View Controller, but you can present custom views that only cover a portion of the screen.

Check out this question for more information

Add UIPickerView & a Button in Action sheet - How?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.