UIReferenceLibraryViewController in UIPopovercontroller - ios

I was recommended to use a UIPopovercontroller in order to display my UIReferenceLIbraryViewController so that the dictionary does not take up the entire screen when I click my UIButton "search"
What I have is a UITextField that takes in the string/word, a button that will search it and pull up the UIReferenceLibraryViewController.
I'm having problems using a popovercontroller to do this. When I tried it, the button doesn't respond. Any tips/help??
edit:
UIReferenceLibraryViewController in a popover
It was originally
if([UIReferenceLibraryViewController dictionaryHasDefinitionForTerm:searchTerm])
{
UIReferenceLibraryViewController *referenceLibraryVC = [[UIReferenceLibraryViewController alloc] initWithTerm:searchTerm];
[self presentModalViewController:referenceLibraryVC animated:YES];
}
which makes it take up the entire ipad screen
Does UIReferenceLIbraryViewController have initWithFrame? that solution didn't seem to work for me either

Thanks to Leo Nathan's help, it works now.
self.masterPopOverController = [[UIPopoverController alloc] initWithContentViewController:referenceLibraryVC];
[self.masterPopOverController presentPopoverFromRect:[sender frame] inView:[sender superview] permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
I didn't connect it correctly in the XIB file and it wasn't implemented in the correct place in the IBAction for ButtonPress

Related

xcode 7.3.1 my storyboard segues to popover are mis-aligned. Objective c

If I simply drag a popover segue from a button, the arrow aligns to the top left of the button, instead of the center.
Anyone have any ideas?
I solve this problems using PopoverController, use UIPopoverControllerDelegate
myPopover = [[UIPopoverController alloc] initWithContentViewController:destinationViewController];
myPopover.delegate = self;
[myPopover presentPopoverFromRect:((UIView *)sender).bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

UIPopoverController presentPopoverFromBarButtonItem allows to press navigation button twice

I am using this code below for presenting UIPopoverController view:
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
So everything works good, but I am still able to press UIBarButtonItem which a sender in the code above.
So do I need to disable this button when the popover is shown by my self or there is some another solution?
Use this method instead, where toolbar is the view containing the sender:
[popover presentPopoverFromRect:sender.frame inView:toolbar permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

iOS- How to add objects in a popoverController in iPhone?

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
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.
Add the elements you want to your UIViewController *popoverViewController. this is the viewcontroller that is displayed in PopoverController * popoverController.

UIBarButtonItem registers click event next to button, not on button

I got the popup, used at 2 locations within my app, one time in a navigation controller one time without navigation controller,
i got one button in a uitoolbar (select button) but this button has it's own life for some reason
The one in the navigation controller is working perfectly.
But the one called without navigation controller resizes this popup so i resized it back in the code like
- (void)showModal:(UIViewController *)controller
{
[controller setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentViewController:controller animated:NO completion:nil]; //Method used without navigationcontroller
[controller.view setBounds:CGRectMake(0,0, 600, 748)]; //resize => button doesn't work at all
//[controller.view setFrame:CGRectMake(0, 0, 600, 748)]; //resize => button only registers click event left from the actual button
//[[NSNotificationCenter defaultCenter] postNotificationName:#"show modal" object:controller]; // Method used within navigationcontroller
}
I've been looking all over google but i can't find anything on this problem.
Hope I have more luck here.
Probably the easy way to sort this problem out is to put it in a UINavigationController and use that to pop up. Then you don't have to use a UIToolBar.
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewControllerToPopUp];
[viewController setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentModalViewController:navController animated:YES];
This way the viewController you are presenting stays simple and you already know the button works when it is a navigation controller :)

UIPickerView issue in iPad

I am repeating this question again because i couldn't find any solution.
My problem i have an XIB where i have labels and a UIPickerView.I am trying to use this XIB inside a UIPopOverController in iPad.But the view is not rendered properly.Actually this is the view which i am adding it to the popover window.
This is the code which i am using
MyPricePickerViewController *priceviewobj=[[MyPricePickerViewController alloc]init];
UINavigationController *navigationcontroller=[[UINavigationController
alloc]initWithRootViewController:priceviewobj];
popover = [[UIPopoverController
alloc]initWithContentViewController:navigationcontroller];
[popover setPopoverContentSize:CGSizeMake(290,410) animated:YES];
[self.popover presentPopoverFromRect:CGRectMake(10,212,20,30) inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
I display other XIBs which dont have a UIPicker view and they are displayed properly.When i run the application the popover is rendered as follows
Please anybody suggest me a possible solution to this problem.Thanks in advance

Resources