UIActionSheet比较标准的写法

- (void)showActionSheetWithButtons:(NSArray *)buttons withTitle:(NSString *)title {

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle: title 
                                                             delegate: self
                                                    cancelButtonTitle: nil 
                                               destructiveButtonTitle: nil 
                                                    otherButtonTitles: nil];

    for (NSString *title in buttons) {
        [actionSheet addButtonWithTitle: title];
    }

    [actionSheet addButtonWithTitle: @"Cancel"];
    [actionSheet setCancelButtonIndex: [buttons count]];
    [actionSheet showInView:[UIApplication sharedApplication].keyWindow];
}

猜你喜欢

转载自lizhuang.iteye.com/blog/2068154