iPhone开发 在模拟器中添加视频

移动开发 iOS
本文介绍的是iPhone开发 在模拟器中添加视频,很有趣的一个小实例,具体实现结果,我们一起来看内容。

iPhone开发 在模拟器中添加视频是本文要介绍对内容,要把视频添加进模拟器,真机上的 iTunes 同步法是没用的。CocoaChina 会员“castielyue”分享了他的视频添加工程,把 video 放在 resource 里,把 viewdidload 里的 video 名改下,运行后就会自动添加到模拟器的相片库里。附件下载 SaveVideo.zip (1068 K)

这里主要用到了以下函数

  1. UIVideoAtPathIsCompatibleWithSavedPhotosAlbum  
  2.  
  3. Returns a Boolean value indicating whether the specified video can be saved to user’s Saved Photos album.  
  4.  
  5. BOOL UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (  
  6.    NSString *videoPath  
  7. ); 

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.

相应的,向模拟器里添加图片的话,可使用这个函数

  1. UIImageWriteToSavedPhotosAlbum  
  2. Adds the specified image to the user’s Saved Photos album.  
  3. void UIImageWriteToSavedPhotosAlbum (  
  4.    UIImage *image,  
  5.    id completionTarget,  
  6.    SEL completionSelector,  
  7.    void *contextInfo  
  8. ); 

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:

  1. - (void) image: (UIImage *) image  
  2.     didFinishSavingWithError: (NSError *) error  
  3.     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.

小结:iPhone开发 在模拟器中添加视频的内容介绍完了,希望本文对你有所帮助!

本文来自:http://www.cocoachina.com/iphonedev/sdk/2010/1229/2520.html

责任编辑:zhaolei 来源: CocoaChina
相关推荐

2011-07-26 09:32:08

iPhone 模拟器

2009-08-20 10:55:59

2011-07-27 17:45:29

iPhone 模拟器 图片

2022-12-30 14:21:54

2011-09-13 17:23:26

2011-06-07 16:58:42

Android 模拟器

2013-07-04 13:29:40

Androidgenymotion

2009-09-14 09:59:19

CCNA模拟器介绍CCNA

2009-08-05 15:23:04

ExtJS Andro

2011-08-18 17:32:55

iPhone开发Table Cell

2011-07-06 13:33:41

iPhone 模拟器 XCode

2010-04-12 17:32:59

Windows Pho

2009-09-04 16:05:08

2011-05-31 09:16:26

Android Mar应用商店Google

2011-07-22 16:22:27

iPhone Lipo 模拟器

2011-07-26 14:18:20

2010-06-21 15:39:59

Windows Pho

2011-08-16 18:56:11

iPhone开发Three20

2012-12-25 12:04:02

Android模拟器教程

2009-09-17 09:11:59

CCNA实验模拟器CCNA
点赞
收藏

51CTO技术栈公众号