UIActionSheet与UITabBarController冲突

1. 继承UIActionSheetDelegate

2.添加视图

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"从相册选择",nil];

    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;

    [actionSheet showInView:self.view.window];       (此处需要注意)

    说明:

  1. UIActionSheetStyleDefault              //默认风格:灰色背景上显示白色文字  
  2. UIActionSheetStyleBlackTranslucent     //透明黑色背景,白色文字  
  3. UIActionSheetStyleBlackOpaque          //纯黑背景,白色文字  
  4. ActionSheet有三种方法:

    1.在一个视图内部显示,可以用showInView

    [mySheet showInView:self];

    2.如果要将ActonSheet 与工具栏或者标签栏对齐,可以使用showFromToolBar或showFromTabBar

    [mySheet showFromToolBar:toolbar];

    [mySheet showFromTabBar:tabbar];



3.相应按钮的点击事件

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

{

    if (buttonIndex == 0) {

    }else if(buttonIndex == 1) {

    }else if(buttonIndex == 2) {

    }

}

你可能感兴趣的:(UIActionSheet与UITabBarController冲突)