How to create Popover in ipad? [closed] - ios

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to develop a popover in my iPad application. A UIButton trigger will call the popover and that popover will contain a UITableViewController.
First I need a popover.
Need some example code or direction or link.
Thanks in advance.

in your viewcontroller on the button action write this code:
- (IBAction)openAllRhymes:(id)sender{
UIButton *button = (UIButton*)sender;
PopupTableView *tableViewController = [[PopupTableView alloc] initWithStyle:UITableViewStylePlain];
popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
[popover presentPopoverFromRect:CGRectMake(button.frame.size.width / 2, button.frame.size.height / 1, 1, 1) inView:button permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[tableViewController release];
}
Now you have created a tableview for popover in that tableviewcontroller write:
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(108,400);

Read the documentation, it's all in there. If you don't understand it, start with general tutorials on iOS development or ask specifically about the parts you don't understand. You will need a solid understanding of how view controllers work before it makes sense to work with popovers. The View Controller Programming Guide also has a section specifically about popovers.

TAableViewController *tableViewController = [[[TAableViewController alloc] initWithNibName:#"TAableViewController" bundle:[NSBundle mainBundle]] autorelease];
UINavigationController *nav = [[UINavigationController alloc]
initWithRootViewController:tableViewController];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:nav];
[nav release];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(320, 497);
[popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Here in this :-
1) TAbleViewController has the table you want to load .
2) i am adding this to the navigation controller
3) navigation controller to the popover

Related

Push a View from popOver in ipad

I open a popOver with a view(DetailView) in a view(MapView). it works fine.
But in my detail view has a button(feedback).so i want to push the another view(feedbackform)on btton clicked.
I tried but nothing is Happened.
Can i push the view inside the popover?
My code is as follow:
// MapView.m
detailsView *popUp=[[detailsView alloc] initWithNibName:#"detailsView_ipad" bundle:nil];
popView = [[UIPopoverController alloc]initWithContentViewController:popUp];
popView.delegate =self;
[popView setPopoverContentSize:CGSizeMake(600, 500)];
[popView presentPopoverFromRect:control.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
//Detailview.m
-(IBAction)openFeedbackForm:(id)sender {
fbView = [[deatailsFeedback alloc]
initWithNibName:#"deatailsFeedback_ipad" bundle:nil];
[self.navigationController pushViewController:fbView animated:YES];
}
To achieve this your detailsView should be a Navigation controller with a root controller to the original detailsView.
This way when you pop the navigationController, you can perform push from your detailsView and that would only affect the popOver view
detailsView *popUpView=[[detailsView alloc] initWithNibName:#"detailsView_ipad" bundle:nil];
UINavigationController *popUpNavController = [[UINavigationController alloc] initWithRootViewController:popUpView];
popView = [[UIPopoverController alloc]initWithContentViewController:popUpNavController];
popView.delegate =self;
[popView setPopoverContentSize:CGSizeMake(600, 500)];
[popView presentPopoverFromRect:control.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
//Detailview.m
-(IBAction)openFeedbackForm:(id)sender {
fbView = [[deatailsFeedback alloc]
initWithNibName:#"deatailsFeedback_ipad" bundle:nil];
[self.navigationController pushViewController:fbView animated:YES];
}
If I understand your code correctly, openFeedForm IBAction method is in Detailview.m?
Meaning the first part of the code is in a different class than the one at the bottom?
If so, since Detailview itself is not in a navigationController, it will not push anything to its non-existant navigation controller.
What you want to do is have MapView push the new view in its navigationController.
Side note: since you are setting the delegate of the popUp in MapView as (self) the IBAction method should be defined in MapView
(This is assuming my first statement about understanding your code is correct)

What kind of popover on iPad

The iPad app pdf expert displays popovers which seem to consist only of the header. Which kind of popover is this? I can't find something about it in the Apple docs. But it seems to be a standard UI element. Or is it a custom view?
Its nothing like a custom view. Its just without UINavigationController.
ViewController *viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
UIPopoverController * popover = [[UIPopoverController alloc] initWithContentViewController:viewController];
popover.delegate = self;
popover.popoverContentSize = CGSizeMake(644, 425);
[popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections: UIPopoverArrowDirectionLeft | UIPopoverArrowDirectionUp animated:YES];
This will solve you problem. Check it out.!!

How to set a navigation bar with title in popover controller [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do you set a navigation bar with a title in a popover controller? I want a detailed explanation, please help me.
Thanks in advance.
SomeViewController *popContentViewController = [[SomeViewController alloc] initWithNibName:#"SomeViewController" bundle:nil];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:popContentViewController];
UIPopoverController popOverController = [[UIPopoverController alloc] initWithContentViewController:controller];
popOverController.delegate = self;
[popContentViewController release];
[controller release];
And in SomeViewController Class in viewDidLoad method write
self.title = #"Text For Title on Navigation Bar";

Dismissing iPad UIPopoverController from within its content controller

So I have a popover with a button in it. When that button is pushed, I want the popover to go away. It seems easy enough, but I can't figure it out for the life of me. The code I use to show the popover is below:
AddCategoryViewController* content = [[AddCategoryViewController alloc] init];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:content];
aPopover.delegate = self;
[content release];
// Store the popover in a custom property for later use.
self.addCategoryPopover = aPopover;
[aPopover release];
[addCategoryPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Within the addcategoryviewcontroller, I have:
-(IBAction)saveAddCategory:(id)sender {
if (rootViewController == nil)
rootViewController = [[RootViewController alloc] init];
[rootViewController.addCategoryPopover dismissPopoverAnimated:YES];
[rootViewController dismissPopover];
}
Rootviewcontroller is where the popover is being created from. Unfortunately, neither of those methods work to dismiss it. any help?
You would be seeing a warning at this line.
aPopover.delegate = self;
and if you would execute your code. The app would crash. Instead you need to do it like this.
I have
- (void)viewWillDisappear:(BOOL)anAnimated
{
[self.dPopover dismissPopoverAnimated: NO];
self.dPopover = nil;
[super viewWillDisappear: anAnimated];
}
and don't see why this wouldn't work in your case.
Your if is a bit troubling, so my guess is you aren't talking to the view you think you are. rootViewController.addCategoryPopover is probably nil, because you made a new controller.
I think I answered just a similar question with the solution I used to dismiss a popover with a UIView loaded from a MKMapView.
The use of my solution is basically the same as for any other view loading a popover.
Have a look at:
How to dismissPopoverAnimated on iPad with UIPopoverController in MKMapView (SDK3.2). I hope that solved your problem.
use NSNotificationCenter To DissmissPoperController Fro Father viewControll

PopoverView issue

i am first time using Popoverview, and i have one issue when i am using popover view.
here is the code which i am using it working fine
objManage = [[xyViewController alloc]init];
aPopover = [[UIPopoverController alloc] initWithContentViewController:objManage];
aPopover.delegate = self;
CGSize size = CGSizeMake(768,1004);
[aPopover setPopoverContentSize:size animated:YES];
CGRect rect = importAddress.frame; //CGRectMake(100.0f, 918, 768,900);
[aPopover presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
[objManage release];
So i am sucessfully open view controller in popoverview.
i have one button in xyViewController class, Ok suppose i click on button popover view dismiss, How can i dismiss popoverview in another class.
Thank you,
You want to call the method dismissPopoverAnimated:(BOOL)animated on the popover
http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIPopoverController_class/Reference/Reference.html#//apple_ref/doc/uid/TP40009306-CH1-SW9

Resources