ios开发——实用技术篇Swift篇&拍照
拍照
// MARK: - 拍照
func fromPhotograph()
{
if UIImagePickerController.isSourceTypeAvailable(.Camera)
{
//创建图片控制器
let picker = UIImagePickerController()
//设置代理
picker.delegate = self
//设置来源
picker.sourceType = UIImagePickerControllerSourceType.Camera
//设置镜头
if UIImagePickerController.isCameraDeviceAvailable(UIImagePickerControllerCameraDevice.Front)
{
picker.cameraDevice = UIImagePickerControllerCameraDevice.Front
}
//设置闪光灯
picker.cameraFlashMode = UIImagePickerControllerCameraFlashMode.On
//允许编辑
picker.allowsEditing = true;
//打开相机
self.presentViewController(picker, animated: true, completion: { () -> Void in
})
}
else
{
let aler = UIAlertView(title: "找不到相机!", message: nil, delegate: nil, cancelButtonTitle: "确定")
aler.show()
}
}
// MARK: - UIImagePickerControllerDelegate
//选择图片成功之后代理
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject])
{
//查看info对象
println(info)
//获取选择的原图
// let image = info[UIImagePickerControllerOriginalImage] as UIImage
//2015年5月2后修改
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
//赋值,图片视图显示图片
picView.image = image
//图片控制器退出
picker.dismissViewControllerAnimated(true, completion: { () -> Void in
})
}
//取消图片控制器代理
func imagePickerControllerDidCancel(picker: UIImagePickerController)
{
//图片控制器退出
picker.dismissViewControllerAnimated(true, completion: { () -> Void in
})
}
// MARK: - UIActionSheetDelegate
func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int)
{
if buttonIndex != actionSheet.cancelButtonIndex
{
//从相册选
{
self.fromAlbum()
} //拍照
{
self.fromPhotograph()
}
}
}
ios开发——实用技术篇Swift篇&拍照的更多相关文章
- ios开发——实用技术篇Swift篇&播放MP3
播放MP3 // MARK: - 播放MP3 /*----- mp3 ------*/ //定时器- func updateTime() { //获取音频播放器播放的进度,单位秒 var cuTime ...
- ios开发——实用技术篇Swift篇&照片选择
照片选择 // MARK: - 选择照片 /*----- 选择照片 ------*/ @IBAction func addImageButtonClick() { let actionSheet = ...
- ios开发——实用技术篇Swift篇&地址薄、短信、邮件
//返回按钮事件 @IBAction func backButtonClick() { self.navigationController?.popViewControllerAnimated(tru ...
- ios开发——实用技术篇Swift篇&系统声音
系统声音 // MARK: - 系统声音 /*----- 系统声音 ------*/ @IBAction func systemSound() { //建立的SystemSoundID对象 var s ...
- ios开发——实用技术篇Swift篇&视频
视频 // MARK: - 播放视频 /*----- 播放视频 ------*/ func moviePlayerPreloadFinish(notification:NSNotification) ...
- ios开发——实用技术篇Swift篇&录音
录音 // MARK: - 录音 /*----- 录音 ------*/ var recorder:AVAudioRecorder? //录音器 var player:AVAudioPlayer? / ...
- ios开发——实用技术篇Swift篇&加速计和陀螺仪
加速计和陀螺仪 //返回按钮事件 @IBAction func backButtonClick() { self.navigationController?.popViewControllerAnim ...
- ios开发——实用技术篇Swift篇&多点触摸与手势识别
多点触摸与手势识别 //点击事件 var atap = UITapGestureRecognizer(target: self, action: "tapDo:") self.vi ...
- ios开发——实用技术篇OC篇&iOS的主要框架
iOS的主要框架 阅读目录 Foundation框架为所有的应用程序提供基本系统服务 UIKit框架提供创建基于触摸用户界面的类 Core Data框架管着理应用程序数据模型 Core ...
随机推荐
- C语言实现strlen
strlen: #ifndef STRLEN_H #define STRLEN_H #include <stdio.h> // 参考微软的写法 int cat_strlen(const c ...
- Android学习笔记-Dialog详解
1.对话框的使用 1.1AlertDialog的显示 简单对话框以及监听的设置:重点掌握三个按钮(也就是三上单词): PositiveButton(确认按钮);NeutralButton(忽略按钮) ...
- Android Audio遇到播放无声时的分析
在Android Audio开发过程中,有遇到播放ringtone时无声,但播放Music可以听到声音,关于无声问题的分析,在此做个笔记,方便以后回顾. 分析方向: 1:在音量控制面板中确认该音频流对 ...
- js获取时间搓
var oData=new Date().getTime(2016-01-16); console.log(oData);
- index structure
1. wordlist 0) 0, 1byte 1) token-id(delta), 8byte 2) doclist-offset(delta), 8byte 3) doc_count, 4byt ...
- 安装php5.5
安装php5.5 ./configure --prefix=/usr/local/php5.5.14/ --with-apxs2=/usr/local/apache2.2.27/bin/apxs -- ...
- poj 3060 Visible Lattice Points
http://poj.org/problem?id=3090 Visible Lattice Points Time Limit: 1000MS Memory Limit: 65536K Tota ...
- 咏南C/S开发框架支持最新的DELPHI XE8开发
特大好消息:咏南C/S开发框架支持最新的DELPHI XE8开发!咏南开发框架让你再无开发工具升级后顾之忧! 购买咏南开发框架送项目源码!
- 原生JS修改标签样式为带阴影效果
代码如下: JS部分 //点击时候,改变样式 function GetCategoryInfo(value) { var getInfo = value.toString().split(','); ...
- .net 配置ueditor
添加引用如下: <script src="../Ueditor/ueditor.config.js" type="text/javascript"> ...