zoukankan      html  css  js  c++  java
  • UIActionSheet跳转相册,拍照

    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;

        }

    }

  • 相关阅读:
    GCD介绍(二): 多核心的性能
    GCD介绍(一): 基本概念和Dispatch Queue
    iOS 中如何监测某段代码运行的时间
    DSOframer 无法正常加载的解决方案
    Hexo 官方主题 landscape-plus 优化
    在 Parallels Desktop 中,全屏模式使用 Win7,唤醒时黑屏
    VS2015 企业版不支持 JavaScript 语法高亮、智能提醒
    解决 Boot Camp 虚拟机升级到 Windows 10 后 Parallels Desktop 不能识别的问题
    利用SkyDrive Pro 迅速批量下载SharePoint Server 上已上传的文件
    SharePoint Server 2013 让上传文件更精彩
  • 原文地址:https://www.cnblogs.com/rankilau/p/4146944.html
Copyright © 2011-2022 走看看