码迷,mamicode.com
首页 > 其他好文 > 详细

UIActionSheet跳转相册,拍照

时间:2014-12-05 16:58:02      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:des   style   io   os   sp   for   on   bs   cti   

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;

    }

}

UIActionSheet跳转相册,拍照

标签:des   style   io   os   sp   for   on   bs   cti   

原文地址:http://www.cnblogs.com/rankilau/p/4146944.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!