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