亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

iOSProgrammingCamera1

2019-11-14 19:03:20
字體:
來源:轉載
供稿:網友

?iOS PRogramming Camera ?1

1 Displaying Images and UIImageView

1.1? put an instance of UIImageView on the screen.

Then drag an instance of UIImageView onto the view and position it below the label.

A UIImageView displays an image according to its contentMode property.

UIImageView根據它的contentMode 屬性來展示圖片。

This property determines where to position and how to resize the content within the image view's frame.

這個屬性決定了在哪兒和在image View的框架內怎樣重新顯示尺寸的內容。

UIImageView's default value for contentMode is UIViewContentModeScaleToFill, which will adjust the image to exactly match the bounds of the image view.

默認是UIViewContentModeScaleToFill。

If you keep the default, an image taken by the camera will be contorted to fit into the square UIImageView.

如果你采用默認設置,你的圖片可能被扭曲以來適應方形的UIImageView。

@property (weak, nonatomic) IBOutlet UIImageView *imageView;

1.2 Adding a camera button?

Now you need a button to initiate the photo-taking process.

現在你需要一個button 來初始化photo-taking process。?

Instead, you will create an instance of UIToolbar and place it at the bottom of BNRDetailViewController's view.

你需要創建一個UIToolBar 的實例把它放在BNRDetailViewController's view 的底部。

?

A UIToolbar works a lot like a UINavigationBar – you can add instances of UIBarButtonItem to it.

where a navigation bar has two slots for bar button items, a toolbar has an array of bar button items. You can place as many bar button items in a toolbar as can fit on the screen.

一個navigation bar 有兩個位置存放bar button items ,a toolbar 有一列 bar button items. 你可以存放任意數量的bar button items 只有屏幕允許。

By default, a new instance of UIToolbar that is created in a XIB file comes with one UIBarButtonItem.

默認情況下,一個UIToolbar 已經有一個UIBarButtonItem。

Select this bar button item and open the attribute inspector. Change the Identifier to Camera, and the item will show a camera icon

選中這個bar button item 并打開attribute inspector . 改變Identifier 到Camera,這樣就會顯示一個camera? 標志。

select the camera button by first clicking on the toolbar and then the button itself. Then Control-drag from the selected button to the implementation part of BNRDetailViewController.m

?

?

?

2 Taking Pictures and UIImagePickerController

In the takePicture: method, you will instantiate a UIImagePickerController and present it on the screen.

在takePic 中你將創建 一個UIImagePickerController并把它展現到屏幕上。

When creating an instance of UIImagePickerController, you must set its sourceType property and assign it a delegate.

當你創建一個UIImagePickerController的實例,你必須設置sourceType屬性并分配給他一個delegate。

2.1 Setting the image picker's sourceType

The sourceType constant that tells the image picker where to get images.

sourceType告訴image picker 從哪里獲取images。

It has three possible values:?

(1)UIImagePickerControllerSourceTypeCamera

The user will take a new picture.?

用戶將獲得一個新的圖片

(2)UIImagePickerControllerSourceTypePhotoLibrary

The user will be prompted to select an album and then a photo from that album.?

將選擇一個album 和在這個albu的一個photo 。

UIImagePickerControllerSourceTypeSavedPhotosAlbum

The user picks from the most recently taken photos.

從最近使用的photos中獲取一個。?

?

The first source type, UIImagePickerControllerSourceTypeCamera, will not work on a device that does not have a camera. So, before using this type, you have to check for a camera by sending the message isSourceTypeAvailable: to the UIImagePickerController class:

第一個source type ,UIImagePickerControllerSourceTypeCamera不會在沒有相機的設備中使用。所以,在使用該類型之前,你需要檢查一個camera 通過發送isSourceTypeAvailable給UIImagePickerController。

+ (BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType;

?

- (IBAction)takePicture:(id)sender

{
UIImagePickerController *imagePicker =

[[UIImagePickerController alloc] init];

// If the device has a camera, take a picture, otherwise,

// just pick from photo library

if ([UIImagePickerController

isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

} else {

imagePicker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;

}

}

2.2 Setting the image picker's delegate

設置image picker 的delegate?

When the user selects an image from the UIImagePickerController's interface, the delegate is sent the message imagePickerController:didFinishPickingMediaWithInfo:. (If the user taps the cancel button, then the delegate receives the message imagePickerControllerDidCancel:.)

當用戶從UIImagePickerController's界面中選中一個image時,這個delegate (接收到消息)被發送消息給imagePickerController:didFinishPickingMediaWithInfo。(如果用戶選擇了cancel button那么delegate會收到imagePickerControllerDidCancel消息。)

The image picker's delegate will be the instance of BNRDetailViewController.

@interface BNRDetailViewController ()
<UINavigationControllerDelegate, UIImagePickerControllerDelegate>

Why UINavigationControllerDelegate??

為什么會有UINavigationControllerDelegate ?

UIImagePickerController's delegate property is actually inherited from its superclass, UINavigationController, and while UIImagePickerController has its own delegate protocol, its inherited delegate property is declared to point to an object that conforms to UINavigationControllerDelegate.

UIImagePickerController's delegate屬性其實繼承自它的超類UINavigationController,當UIImagePickerController擁有它自己的delegate protocol ,它繼承的delegate 屬性被指向一個服從了UINavigationControllerDelegate的對象。

imagePicker.delegate = self;

?

2.3 Presenting the image picker modally

Once the UIImagePickerController has a source type and a delegate, it is time to get its view on the screen.

一旦UIImagePickerController有source type和delegate,就是該讓view 顯示在屏幕上了。

Unlike other UIViewController subclasses you have used, an instance of UIImagePickerController is presented modally.

不像其他的UIViewController的子類,UIImagePickerController的實例展現modally .

A modal view controller takes over the entire screen until it has finished its work.

一個modal view controller 占用了整個屏幕直到它完成工作。

To present a view controller modally, you send presentViewController:animated:completion: to the UIViewController whose view is on the screen.

你需要發送presentViewController:animated:completion給誰的view 在屏幕上的UIViewController。?

// Place image picker on the screen
[self presentViewController:imagePicker animated:YES completion:nil];

2.4 Saving the image

you do not have a reference to the photo once the image picker is dismissed. To fix this, you are going to implement the delegate method imagePickerController:didFinishPickingMediaWithInfo:. This message is sent to the image picker's delegate when a photo has been selected.

你需要實現delegate 方法:imagePickerController:didFinishPickingMediaWithInfo。當一個photo 被選中,這個方法被送給image? picker的委托 。

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

{
// Get picked image from info dictionary
UIImage *image = info[UIImagePickerControllerOriginalImage];

// Put that image onto the screen in our image view

self.imageView.image = image;

// Take image picker off the screen -
// you must call this dismiss method
[self dismissViewControllerAnimated:YES completion:nil];

}

?

The solution, which you are going to implement in the next section, is to store images to disk and only fetch them into RAM when they are needed.

解決辦法是把圖片存儲到disk,當它們的時候再去創建他們。

?

?

?

?

?

?


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
日韩精品免费在线| 永久免费毛片在线播放不卡| 欧美性猛交xxxx黑人| 国内成人精品视频| 亚洲女人被黑人巨大进入al| 亚洲91精品在线观看| xxxx性欧美| 精品动漫一区二区三区| 97在线精品国自产拍中文| 97国产一区二区精品久久呦| 亚洲精品免费av| 揄拍成人国产精品视频| 久久久国产视频91| 亚洲电影第1页| 国产精品视频一区二区高潮| 久久国产精品视频| 亚洲免费电影在线观看| 亚洲老头同性xxxxx| 欧美性色视频在线| 日韩在线视频二区| 久久久久久中文| 国产亚洲精品久久久优势| 黑人精品xxx一区一二区| 国内外成人免费激情在线视频| 一区二区三区无码高清视频| 91成人国产在线观看| 欧美精品久久久久a| 久久国产精品久久久久久久久久| 国产成人激情视频| 欧美性高潮在线| 亚洲综合视频1区| 久久精品国产亚洲精品2020| 亚洲精品一区中文| 另类视频在线观看| 亚洲电影在线看| 亚洲午夜av电影| 国产91精品不卡视频| 精品久久久久久久久久国产| 欧美成aaa人片免费看| 亚洲第一网站免费视频| 欧美亚洲国产日韩2020| 国产精品盗摄久久久| 久久伊人91精品综合网站| 欧美日韩亚洲一区二区三区| 亚洲电影成人av99爱色| 久久久久久久久久久免费| 久久好看免费视频| 国产成人精品999| 日韩免费高清在线观看| 国产成人精品免高潮费视频| 日韩欧美亚洲一二三区| 日韩在线国产精品| 91中文字幕在线| 日韩av中文字幕在线免费观看| 亚洲精品乱码久久久久久按摩观| 成人黄色影片在线| 国产成人精品999| 亚州欧美日韩中文视频| 久久精视频免费在线久久完整在线看| 亚洲成人黄色在线| 亚洲欧美一区二区激情| 欧美人在线观看| 91色在线观看| 久久精品国产亚洲精品| 精品视频偷偷看在线观看| 精品视频—区二区三区免费| 国产精品狠色婷| 久久青草福利网站| 久久久久久久久爱| 国产精品精品国产| 欧美黄色片免费观看| www.亚洲一区| 欧美亚洲另类制服自拍| 国产精品三级久久久久久电影| 在线看日韩av| www.久久草.com| 久久亚洲精品一区| 国产午夜精品免费一区二区三区| 日韩精品免费在线视频观看| 国内精品久久久久久久久| 成人a免费视频| 91精品久久久久久久久中文字幕| 黑人巨大精品欧美一区二区一视频| 久久精品美女视频网站| 久久精品2019中文字幕| 菠萝蜜影院一区二区免费| 精品国内亚洲在观看18黄| 亚洲电影免费观看| 91亚洲精品在线| 日韩黄色在线免费观看| 97精品免费视频| 亚洲久久久久久久久久久| 日本免费一区二区三区视频观看| 国产成人激情小视频| 色99之美女主播在线视频| 欧美精品做受xxx性少妇| 日韩av电影在线网| 国产精品色婷婷视频| 国产精品久久久久久久天堂| 成人国产在线视频| 国产一区二区三区18| 久久久久久久久久国产精品| 亚洲精品中文字幕有码专区| 国产精品久久久久久久久久久久久久| 国模吧一区二区三区| 欧美亚洲国产精品| 国产精品久久久久久中文字| 日韩最新中文字幕电影免费看| 久久99亚洲精品| 在线不卡国产精品| 亚洲欧美日韩精品久久奇米色影视| 成人欧美一区二区三区黑人| 欧美二区在线播放| 亚洲色图17p| 久久av中文字幕| 亚洲人成自拍网站| 2019中文字幕在线免费观看| 国产精品久久久久久久久久三级| 欧美精品久久一区二区| 亚洲人成77777在线观看网| 欧美一区二区影院| 精品视频一区在线视频| 国产欧美日韩精品丝袜高跟鞋| 亚洲国产精品嫩草影院久久| 亚洲久久久久久久久久久| 久久久久久中文| 国产欧美精品va在线观看| 韩国v欧美v日本v亚洲| 欧美激情第1页| 欧美大尺度激情区在线播放| 国产日产久久高清欧美一区| 欧美多人乱p欧美4p久久| 亚洲字幕在线观看| 一区二区日韩精品| 在线一区二区日韩| 中文字幕国产亚洲2019| 午夜精品在线观看| 亚洲va久久久噜噜噜| 精品国产乱码久久久久久婷婷| 色综合久久久888| 伊人久久久久久久久久久| 成人h视频在线观看播放| 欧美性做爰毛片| 亚洲精品v欧美精品v日韩精品| 久久69精品久久久久久久电影好| 亚洲图片欧洲图片av| 日韩欧美在线视频日韩欧美在线视频| 在线观看精品国产视频| 视频在线观看99| 国产日本欧美视频| 欧美成人午夜激情| 中文字幕不卡在线视频极品| 欧美精品久久一区二区| 欧美诱惑福利视频| www国产精品com| 欧美日产国产成人免费图片| 2025国产精品视频| 91精品国产91久久久| 欧美福利在线观看| 欧美怡春院一区二区三区| 日韩精品福利在线| 亚洲美女又黄又爽在线观看| 久久久久国色av免费观看性色| 色av中文字幕一区|