iOSdia调用系统相册

1.点击按钮触发事件,调用系统的相册

#pragma mark 点击事件

- (void)onClickCarmerButton

{

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"请选择照片的来源" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"从相册选择",@"拍照", nil];

[sheet showInView:self.view];

}

#pragma mark ActionSheetDelegate

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

{

UIImagePickerController *imageVC = [[UIImagePickerController alloc] init];

imageVC.delegate = self;

if (buttonIndex == 0) {

imageVC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

}else if (buttonIndex == 1) {

imageVC.sourceType = UIImagePickerControllerSourceTypeCamera;

}else if (buttonIndex == 2) {

return;

}

[self presentViewController:imageVC animated:NO completion:nil];

}

#pragma mark - UIImagePickerController Delegate

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

UIImage *image = info[UIImagePickerControllerOriginalImage];

//    [self uploadImage:image];

[self dismissViewControllerAnimated:YES completion:nil];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

{

[self dismissViewControllerAnimated:YES completion:nil];

}

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

{

// bug fixes: UIIMagePickerController使用中偷换StatusBar颜色的问题

if ([navigationController isKindOfClass:[UIImagePickerController class]] &&

((UIImagePickerController *)navigationController).sourceType ==     UIImagePickerControllerSourceTypePhotoLibrary) {

[[UIApplication sharedApplication] setStatusBarHidden:NO];

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

}

[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];

//    [navigationController.navigationBar setTintColor:[UIColor whiteColor]];

}

以上代码只是大体步骤

时间: 2024-07-30 02:48:47

iOSdia调用系统相册的相关文章

Android 调用系统相机拍照保存以及调用系统相册的方法

系统已经有的东西,如果我们没有新的需求的话,直接调用是最直接的.下面讲讲调用系统相机拍照并保存图片和如何调用系统相册的方法. 首先看看调用系统相机的核心方法: Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(camera, CAMERA); 相机返回的数据通过下面的回调方法取得,并处理: public static final int CAMERA  = 0x01; @Over

调用系统相册

import android.app.Activity; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.support.v7.app.AppCompatA

android 调用系统相机获取图片、调用系统相册获取图片,并对图片进行截取

打开系统相册获取图片并截取,代码相对简单 1 Intent intent = new Intent(Intent.ACTION_GET_CONTENT,null); 2 intent.setType("image/*"); 3 intent.putExtra("crop", "true"); 4 5 //WIDTH 和 HEIGHT指的是截取框的宽高比例,如设WIDTH = 1,HEIGHT = 1,截取框就为正方形 6 intent.putEx

调用系统相册或相机工具类

需求:点击修改头像,弹出对话框提示选择相册还是相机,从而调用系统相册或相机 import android.app.Activity; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import

安卓 调用系统相册并裁剪

上一篇写了关于调用系统相机并裁剪,这一片写关于调用系统相册裁剪照片 btn_album.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent; logoTempPath = LOGO_BASE_PATH + System.currentTimeMillis() + ".png"; intent = new Intent(Intent.ACTION_

Swift—调用系统相册和相机

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #000000 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #000000; min-height: 28.0px } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #294c50 }

iOS调用系统相册、相机 显示中文标题

最近做头像上传功能需要使用系统相册.相机,在调用系统相册.相机发现是英文的系统相簿界面后标题显示"photos",但是手机语言已经设置显示中文,纠结半天,最终在info.plist设置解决问题. 发现在项目的info.plist里面添加Localized resources can be mixed YES(表示是否允许应用程序获取框架库内语言)即可解决这个问题.特此记录下以便以后查看和别人解决问题

Swift开发之调用系统相册

对于iOS 中调用系统相册的功能,我想大家都比较熟悉了,但是Swift语言调用可能很多伙伴们不是很清楚,毕竟Swift是一门新语言,所以语法和实现方法可能不是很清楚,所以今天做了一个demo,大家可以做一下参考. // //  ViewController.swift //  iOS // //  Created by 悦兑科技 on 15/1/12. //  Copyright (c) 2015年 BSY. All rights reserved. // import UIKit class

Android调用系统相册和相机选择图片并显示在imageview中

Android调用系统相册和相机选择图片并显示在imageview中,在系统调用相机拍摄中,直接返回的是经过压缩处理后的图像,当你直接把返还后的图片放在imageview中时 图片就会非常的模糊,所以要经过先存放在sd中,然后在处理并显示.当调用系统相册时,因为Android系统从4.4版本以后系统不再返回真实的uri路径,而是封装过后的uri路径,所以当你写代码时必须注意,4.4是一个分水岭,4.4以上的版本必须就通过解析和相应的处理才能获取到真实的uri路径. 先上程序运行的结果. 这个是调