-1

In my app, I have a button, when it is clicked a popoverView will be displayed.
I used the following code
First, I added UIPopover+Iphone.h and UIPopover+Iphone.m files from the link Popover view for iPhone using XCode 5

-(IBAction)buttonClicked:(id)sender
{
   UIViewController *popoverViewController=[[UIViewController alloc]init];
   UIPopoverController * popoverController=[[UIPopoverController alloc]initWithContentViewController:popoverViewController];
popoverController.popoverContentSize=CGSizeMake(200, 200);
   [popoverController presentPopoverFromRect:timingTextField.frame inView:self.view permittedArrowDirections: UIPopoverArrowDirectionUp animated:YES];
}  

I got an output like this
enter image description here

Now I want to insert some objects in it, say a button or some other equivalent UI element. Can anyone please suggest me something. Thanks in advance.

Community
  • 1
  • 1
chandru
  • 407
  • 1
  • 5
  • 26

1 Answers1

1

Add the elements you want to your UIViewController *popoverViewController. this is the viewcontroller that is displayed in PopoverController * popoverController.

Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56
thorb65
  • 2,696
  • 2
  • 27
  • 37
  • then show the code where you add the elements. in your code you add an empty view controller. – thorb65 Dec 18 '13 at 09:12
  • What U say is this,right, [popoverViewController addSubview:button]; – chandru Dec 18 '13 at 09:14
  • I cant use this at all – chandru Dec 18 '13 at 09:15
  • yes. but before you add the button you have to initialize the button correct with the correct value for his frame – thorb65 Dec 18 '13 at 09:15
  • It is showing an error No visible @interface for 'UIViewController' declares the selector 'addSubview:' – chandru Dec 18 '13 at 09:17
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/43405/discussion-between-chandru-and-thorb) – chandru Dec 18 '13 at 09:19
  • 1
    you have to call [popoverViewController.view addSubview:yourButton] – thorb65 Dec 18 '13 at 09:21
  • I have 5 text fields in my view, but i need to use this in only one field. I used the above code in textfieldBeginEdition metjod, I get an error, wen I click other fields also this popover view is displayed – chandru Dec 18 '13 at 10:26