开发者

How to create Popover in ipad? [closed]

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜