UIActionsheet的简化版本,其实是放置在pop-over里面的,所以具备dismiss//在空白处点击完成框消失
- (IBAction)doOtherThing:(id)sender {
NSLog(@"imagine that this summons a popover"); } - (IBAction)doButton:(id)sender { UIActionSheet* act = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Hey", @"Ho", nil]; // [act showFromBarButtonItem:sender animated:YES]; [act showFromRect:CGRectMake(100, 100, 10, 10) inView:self.view animated:YES]; } // without this stuff, the toolbar buttons would be active while the action sheet popover is up // comment them out and see // however, the fact that this is necessary seems like a huge bug to me - (void)didPresentActionSheet:(UIActionSheet *)actionSheet { [self.toolbar setUserInteractionEnabled:NO]; } - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { //Sent to the delegate after an action sheet is dismissed from the screen... ... ... [self.toolbar setUserInteractionEnabled:YES]; NSLog(@"pressed %i", buttonIndex); }代码简单,明了,没啥特别的:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.rootViewController = [RootViewController new];
Action的外形需要自定义的不多,基本比较统一,主要是显示位置
[act showFromBarButtonItem:sender animated:YES]; [act showFromRect:CGRectMake(100, 100, 10, 10) inView:self.view animated:YES];
act showFromTabBar:
act showFromToolBar:
act showInView:<#(UIView *)#>