UIActionSheet用法


//上拉菜单
1
UIActionSheet* sheet = [[UIActionSheet alloc] 2 initWithTitle:nil 3 delegate:self 4 cancelButtonTitle:@"取消" 5 destructiveButtonTitle:@"确定" 6 otherButtonTitles:@"拍照",@"选择本地照片",nil]; 7 [sheet showInView:self.view]; 8 9 (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 10 { 11 if (buttonIndex == 0) { 12 [self showAlert:@"拍照"]; 13 }else if (buttonIndex == 1) { 14 [self showAlert:@"选择本地照片"]; 15 }else if(buttonIndex == 2) { 16 [self showAlert:@"取消"]; 17 }else if(buttonIndex == 3) { 18 [self showAlert:@"确定"]; 19 } 20 21 } 22 - (void)actionSheetCancel:(UIActionSheet *)actionSheet{ 23 24 } 25 -(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{ 26 27 } 28 -(void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex{ 29 30 }

 

 1 [self showAlert:@"拍照"];
 2 
 3 //弹出对话框
 4 - (void)showAlert:(NSString *)message{
 5     UIAlertView *alertView = [[UIAlertView alloc]
 6                               initWithTitle:nil
 7                               message:message
 8                               delegate:self
 9                               cancelButtonTitle:@"Cancel"
10                               otherButtonTitles:@"OK", nil];
11     
12     [alertView show];
13 }

 

posted @ 2013-08-01 18:13  wangzhenxiang  阅读(217)  评论(0编辑  收藏  举报