博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UIActionSheet跳转相册,拍照
阅读量:4320 次
发布时间:2019-06-06

本文共 1561 字,大约阅读时间需要 5 分钟。

UIImagePickerController *camera;

//点击tableView上得按钮,弹出UIActionSheet

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    [tableView deselectRowAtIndexPath:indexPath animated:NO];

    

    if (indexPath.section == 0)

    {

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

        [actionSheet showInView:self.view];

        actionSheet.destructiveButtonIndex = 0;

    }

    else if (indexPath.section == 1)

    {

        

        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

        

        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"输入新名字" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

        alertView.alertViewStyle = UIAlertViewStylePlainTextInput;

        

        [alertView show];

        

        

        //得到输入框

        UITextField *tf=[alertView textFieldAtIndex:0];

        tf.placeholder = cell.detailTextLabel.text;

    }

}

//点击UIActionSheet上得按钮,弹出相机,相册

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

{

    [self.view endEditing:YES];

    

    switch (buttonIndex)

    {

        case 1:

            

            if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])

            {

                camera.sourceType = UIImagePickerControllerSourceTypeCamera;

            }

            

            [self presentViewController:camera animated:YES completion:nil];

            break;

        case 0:

            

            camera.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

            [self presentViewController:camera animated:YES completion:nil];

            

            break;

        default:

            break;

    }

}

转载于:https://www.cnblogs.com/rankilau/p/4146944.html

你可能感兴趣的文章
今天才知道原来我还没弄清楚js中全局变量和局部变量的定义...
查看>>
用户心理特征
查看>>
【z05】聪明的质检员
查看>>
【5001】n皇后问题
查看>>
【codeforces 796D】Police Stations
查看>>
数据库事务与锁详解
查看>>
linux 配置ssh免密码登录
查看>>
《重构》的读后感
查看>>
MySQL索引分析和优化
查看>>
DB2中通用的存储进程分页法度典范
查看>>
Fetchmail 6.3.8
查看>>
俄罗斯邮政将迁移到Linux 有关机构已末尾测试Linux
查看>>
SunOS 4上MySQL详尽事变
查看>>
python升级后pip 不可用 卸载pip
查看>>
推送kafka消息失败
查看>>
Nginx日志增长过快详细分析
查看>>
View Controller Programming Guid for iOS 笔记
查看>>
[模板] 最大流和费用流分别的两种做法
查看>>
python 最大连续子数组的和
查看>>
Python中的闭包
查看>>