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
Related
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];
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];
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
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.
Im trying to load a modal view from a view controller that is displayed in a popover. The modal view loads but the problem is that it transitions into the main view and not within the popover. Is it something Im missing? I thought simply initiating it from a vc within a popover would present the modal view within the same popover...
The code is nothing special as bellow:
- (IBAction)myButton{
ModalVC *controller = [[ModalVC alloc] initWithNibName:#"ModalVC" bundle:nil];
[self presentModalViewController:controller animated:YES];
[controller release]; }
If you add
controller.modalPresentationStyle = UIModalPresentationCurrentContext;
before the call to presentModalViewController:animated your ModalVC should be displayed within the popover.
Another way to display something modally in a popover is to use the property modalInPopover.
Unfortunately, it seems you cannot to this and it violates the HIG. From Apple's View Controller Programming Guide
Note: You should always dismiss the visible popover before displaying
another view controller modally. For specific guidelines on when and
how to use popovers in your application, see “Popover (iPad Only)” in
iOS Human Interface Guidelines.
It's because you presentModalViewController to self. Try to add a UIBarButtonItem in your ViewController (self) and do:
[controller presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
where sender is the UIBarButtonItem