Search code examples
iosbuttonpopuptap

How to pop up the EditText box when button is tapped,objective c,ios


How to pop up the Edit Text box when the button is tapped using objective c.Am trying to do but i want some help.Can some body provide some samples for me.I made googling but am not able to find the solution.Please some body help me?


Solution

  • Ok, this is rather easy if I understood correctly what you need.

    First, you need to make a new UIViewController, called let's say TextViewController

    Inside TextViewController you place your UITextView, making it as big as you need, changing the font or whatever you might need/want.

    After this all you need to do is to present TextViewController inside an UIPopoverController ( http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPopoverController_class/Reference/Reference.html ) The code should look something like this

    TextViewController* textViewController = [[TextViewController alloc] init];

    UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:textViewController];

    aPopover.popoverContentSize = CGSizeMake(320.0,110.0); //sets the size of the popover

    [aPopover presentPopoverFromRect:yourButton.frame inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    where textViewController is the view controller with the UITextView and yourButton is the rounded button you tap on.

    This tutorial should also be useful: http://www.raywenderlich.com/1056/ipad-for-iphone-developers-101-uipopovercontroller-tutorial