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.

Dave
  • 4,038
  • 9
  • 45
  • 57

2 Answers2

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

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • that helps. thank you. can you please elaborate on the animations for sliding from the bottom bar? – Dave Mar 12 '10 at 06:40
  • @Dave: Just set the transition style and present the modal view controller. – kennytm Mar 12 '10 at 09: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 Mar 12 '10 at 22:40
  • @Dave: A modal view controller always cover the whole page. – kennytm Mar 13 '10 at 05:30
  • well then I guess I need to add a sub view, in that case, right? Please see my updated question [above]. – Dave Mar 15 '10 at 20:59
  • @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 Mar 15 '10 at 21:06
  • you are right, Kenny. http://stackoverflow.com/questions/2450594/uiview-transition-and-animation – Dave Mar 17 '10 at 18:51
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?

Community
  • 1
  • 1