UIActionSheet常用属性(控件8.3之后失效)

UIActionSheet的集成关系:
UIActionSheet:UIView:UIResponder:NSObject

- (void)viewDidLoad
{
    [super viewDidLoad];
    /**
     1、初始化

         - initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:
     */
    UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"分享测试"
                                                            delegate:self
                                                   cancelButtonTitle:@"取消"
                                              destructiveButtonTitle:@"完成"
                                                   otherButtonTitles:@"微博",@"微信", nil];

    /**
     2、设置属性

         .title             //设置标题
         .visible           //获取是否显示,判断控件是否显示 (只读属性)
         .actionSheetStyle  //设置类型
     */
    actionSheet.title = @"分享测试一下";


    /**
     3、配置按钮

         - addButtonWithTitle:      //添加新的按钮
         .numberOfButtons           //总的按钮数
         .cancelButtonIndex         //取消按钮的index
         .destructiveButtonIndex    //特殊标记按钮的index        注意:如果销毁按钮不为nil,则index==0;否则为-1。
         .firstOtherButtonIndex     //第一个其他按钮的index   注意:如果销毁按钮为nil,则第一个其他按钮的index==1;否则为0。
         - buttonTitleAtIndex:      //根据索引,获取按钮的标题
     */
    [actionSheet addButtonWithTitle:@"QQ"];
    NSLog(@"numberOfButtons:%ld",       (long)actionSheet.numberOfButtons);
    NSLog(@"cancelButtonIndex:%ld",     (long)actionSheet.cancelButtonIndex);
    NSLog(@"destructiveButtonIndex:%ld",(long)actionSheet.destructiveButtonIndex);
    NSLog(@"firstOtherButtonIndex:%ld", (long)actionSheet.firstOtherButtonIndex);
    NSLog(@"buttonTitleAtIndex2:%@",[actionSheet buttonTitleAtIndex:2]);


    /**
     4、几种弹出方式,会根据风格不同展现不同的方式

         - showFromTabBar:
         - showFromToolbar:
         - showInView:
         - showFromBarButtonItem:animated:
         - showFromRect:inView:animated:
     */
    [actionSheet showInView:self.view];


    /**
     5、回收ActionSheet

         - dismissWithClickedButtonIndex:animated:
     */


    /**
     6、代理

         .delegate          //设置代理
         - actionSheet:clickedButtonAtIndex:        //点击按钮时触发的方法

         - willPresentActionSheet:                  //视图将要弹出时触发的方法
         - didPresentActionSheet:                   //视图已经弹出式触发的方法
         - actionSheet:willDismissWithButtonIndex:  //点击按钮后,视图将要收回时触发的方法
         - actionSheet:didDismissWithButtonIndex:   //点击按钮后,视图已经收回时触发的方法

         - actionSheetCancel:
     */
}

这里写图片描述

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值