IOS 开发学习32 actionSheet的使用

头文件

@interface sheetviewViewController : UIViewController<UIActionSheetDelegate> 

@end  

弹出actionSheet

  UIActionSheet *actionSheet = [[UIActionSheet alloc]
                                  initWithTitle:_str_title
                                  delegate:self
                                  cancelButtonTitle:@"取消"
                                  destructiveButtonTitle:nil
                                  otherButtonTitles:nil];


    [actionSheet addButtonWithTitle:@"一个选项"];

    actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [actionSheet showInView:self.view];

定义重写方法


-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if(buttonIndex<1)return; } - (void)actionSheetCancel:(UIActionSheet *)actionSheet{ NSLog(@"cancel"); } -(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{ NSLog(@"didDismiss"); } -(void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{ NSLog(@"willDismiss"); } 

你可能感兴趣的:(ios,interface)