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;

        }

    }

  • 相关阅读:
    thrift python安装
    第二周习题F
    Equivalent Strings
    生成可重集的排列(方法)
    分数拆分(刘汝佳紫书P183)
    Prime ring problem
    Maximun product
    Division
    每周一赛(E题,广搜求方案)
    ICE CAVE(BFS搜索(模拟))
  • 原文地址:https://www.cnblogs.com/rankilau/p/4146944.html
Copyright © 2011-2022 走看看