ESPopoverWithChoices
一个依赖于 WEPopover 的相对简单的辅助类,用于显示具有选择项的弹出窗口。只需将此存储库和 WEPopover 子模块(以及相关资源)中的类包含到您自己的项目中即可。
- (void)displayChoices:(UIBarButtonItem *)sender
{
ESPopoverChoicesSelectionController *contentViewController = [[ESPopoverChoicesSelectionController alloc] initWithStyle:UITableViewStylePlain];
contentViewController.delegate = self;
contentViewController.choices = [NSArray arrayWithObjects:
[ESPopoverChoice popoverChoiceWithName:@"Choice One" value:[NSNumber numberWithInteger:EnumValueForChoiceOne]],
[ESPopoverChoice popoverChoiceWithName:@""Choice Two" value:[NSNumber numberWithInteger:EnumValueForChoiceTwo]],
[ESPopoverChoice popoverChoiceWithName:@""Choice Three" "value:[NSNumber numberWithInteger:EnumValueForChoiceThree]],
nil];
self.popoverController = [[[WEPopoverController alloc] initWithContentViewController:contentViewController] autorelease];
[self.popoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
[contentViewController release];
}
具有简单的代理处理方法
- (void)popoverChoicesSelectionController:(ESPopoverChoicesSelectionController *)controller didSelectChoice:(ESPopoverChoice *)choice
{
if (choice) {
NSInteger theChoiceEnumValue = [choice.value intValue];
. . .
}
[self.popoverController dismissPopoverAnimated:YES];
self.popoverController = nil;
}