您的位置:首页 > 移动开发 > Objective-C

Objective-C-iOS常用小控件(UIActionSheet )动作列表

2016-09-22 09:07 302 查看
//UIActionSheet 动作列表

- (void)createActionSheet{

    //创建列表

    UIActionSheet *actionSheet = [[UIActionSheet
alloc]initWithTitle:@"请选择联系方式"
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:nil
otherButtonTitles:@"打电话",@"发邮件",@"发短信",
nil];

    

    //显示

    

    //设置代理

//    actionSheet.delegate = self;

    

    //设置title

//    actionSheet.title = @"请选择";

    

    //设置放风格

    actionSheet.actionSheetStyle =
UIActionSheetStyleDefault;//默认风格,灰色背景,白色文字

    actionSheet.actionSheetStyle =
UIActionSheetStyleAutomatic;//自动

    actionSheet.actionSheetStyle =
UIActionSheetStyleBlackOpaque;//透明黑色背景,白色文字

    actionSheet.actionSheetStyle =
UIActionSheetStyleBlackTranslucent;//纯黑背景,白色文字

    

    //添加按钮

    [actionSheet addButtonWithTitle:@"京津追梦人"];

    

    //总的按钮数

    NSInteger nums = actionSheet.numberOfButtons;

    

   
//取消按钮的下标

    NSInteger cancelIndex = actionSheet.cancelButtonIndex;

    

   
//点击取消按钮让表消失

    //- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;

    

    [actionSheet showInView:self.view];

    

}

//代理方法

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

   
//可以知道点击了第几项。

    NSLog(@"点击了第%zd个按钮",buttonIndex);

    

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息