惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

博客园 - 胖胖安

Xamarin.Android 的 Google 登入 Xamarin.iOS 的 Google 登入 Xamarin.Android 的照相機使用 Xamarin.iOS 的鍵盤控制 (AutoLayout 與 新的 Keyboard 事件 ) Xamarin.Android 控制鍵盤縮放 Xamarin 環境建置–Xamarin Agent install rvm iOS : TableView MultiSelect 兩個 System.IO.FileInfo 的 Extension Method SQL Server 2008 Resize LDF IIS 7 站點下,ASP.NET 3.5 與 4.0 的並存問題 jQuery AutoComplete Parameters Tips : SQL Server 2008 "saving changes is not permitted." 的解決辦法 - 胖胖安 Section 3 : 程式進入點 Section 2 : 專案結構 Section 1 : 使用 XCode 建立一個新專案 iPhone 開發前的準備工作 IIS 7 上 设定ASP.NET 时应注意事项 DBML 在Beta2與正式版間差異 - 胖胖安 - 博客园
Xamarin.iOS 照相機功能的使用 (1) :最簡單的做法
胖胖安 · 2016-04-14 · via 博客园 - 胖胖安

iOS 提供我們幾種不同的方法使用照相機並且儲存於相簿。

Xamarin.iOS 當然也可以很快地使用這樣的方法,使用照相機功能。

在這之前我們可以先稍微了解一下基本結構,如下圖。

若是有DirectX (DirectInput) 或是OpenGL ES 操作經驗的朋友就可以發現基本上的概念並沒有差很多。
都是從獲取device開始,到準備好接收輸出的 byte[] 並管理,到決定輸出的格式為何。

我們現在先使用最簡單的 UIImagePickerController 來實現照相機功能

btnUIImagePickerViewController.TouchUpInside += (object sender, EventArgs e) => {

                UIImagePickerController imagePickerViewController;

                imagePickerViewController = new UIImagePickerController();

                imagePickerViewController.SourceType = UIImagePickerControllerSourceType.Camera ;

                imagePickerViewController.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary );

                imagePickerViewController.FinishedPickingMedia += (object qsender, UIImagePickerMediaPickedEventArgs ie) => {

                    resultImageView.Image = ie.OriginalImage;

                    imagePickerViewController.DismissViewControllerAsync( true );
                };

                imagePickerViewController.Canceled += (object psender, EventArgs pe) => {


                    imagePickerViewController.DismissViewControllerAsync( true );
                };

                PresentViewController( imagePickerViewController, true, null);

            };

其中 btnUIImagePickerViewController 是在 View上置放的 UIButton文字為Camera - UIImagePickerViewController ,resultImageView 是在View上置放的 UIImageView


這樣就可以很快透過 UIImagePickerViewController 完成使用Camera拍照的功能。

程式碼位置:https://github.com/FangHuaiAn/Xamarin-iOSTips