iPhone開發(fā) 在模擬器中添加視頻
iPhone開發(fā) 在模擬器中添加視頻是本文要介紹對(duì)內(nèi)容,要把視頻添加進(jìn)模擬器,真機(jī)上的 iTunes 同步法是沒用的。CocoaChina 會(huì)員“castielyue”分享了他的視頻添加工程,把 video 放在 resource 里,把 viewdidload 里的 video 名改下,運(yùn)行后就會(huì)自動(dòng)添加到模擬器的相片庫(kù)里。附件下載 SaveVideo.zip (1068 K)。
這里主要用到了以下函數(shù)
- UIVideoAtPathIsCompatibleWithSavedPhotosAlbum
- Returns a Boolean value indicating whether the specified video can be saved to user’s Saved Photos album.
- BOOL UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (
- NSString *videoPath
- );
Parameters
videoPath
The filesystem path to the movie file you want to save.
Return Value
YES if the video can be saved to the photo album or NO if it cannot.
Discussion
Not all devices are able to play video files placed in the user’s Saved Photos album. So, before attempting to save videos to the user’s camera roll, you should call this function to ensure that saving the video is supported for the current device.
相應(yīng)的,向模擬器里添加圖片的話,可使用這個(gè)函數(shù)
- UIImageWriteToSavedPhotosAlbum
- Adds the specified image to the user’s Saved Photos album.
- void UIImageWriteToSavedPhotosAlbum (
- UIImage *image,
- id completionTarget,
- SEL completionSelector,
- void *contextInfo
- );
Parameters
image
The image to write to the user’s device.
completionTarget
The object whose selector should be called after the image has been written to the user’s device.
completionSelector
The method selector, of the target object, to call. This optional method should be of the form:
- - (void) image: (UIImage *) image
- didFinishSavingWithError: (NSError *) error
- contextInfo: (void *) contextInfo;
contextInfo
An optional pointer to any context-specific data that you want passed to the completion selector.
Discussion
The use of the completionTarget, completionSelector, and contextInfo parameters is optional and necessary only if you want to be notified asynchronously when the function finishes writing the image to the user’s Saved Photos album. If you do not want to be notified, pass nil for these parameters.
小結(jié):iPhone開發(fā) 在模擬器中添加視頻的內(nèi)容介紹完了,希望本文對(duì)你有所幫助!
本文來(lái)自:http://www.cocoachina.com/iphonedev/sdk/2010/1229/2520.html