How to show button popover on iPad

CGRect contentRect = CGRectMake(0, 0, 200, 40);
UIButton *source = [UIButton buttonWithType:UIButtonTypeCustom];
source.frame = contentRect;

source.titleLabel.text = @”Delete”;

source.backgroundColor = [UIColor redColor];

UIViewController* popoverContent = [[UIViewController alloc] init];
popoverContent.view = source;

popoverContent.contentSizeForViewInPopover = contentRect.size;

UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];

[popoverController presentPopoverFromRect:[sender frame]
inView:window
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];

[popoverContent release];

Blogged with the Flock Browser

Tags: , ,

Advertisements

One Response to “How to show button popover on iPad”

  1. Stephanie Says:

    Thanks for this 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: