简体   繁体   English

iOS 5:使用StoryTable将使用UITableView中加载的资产对象显示在另一个ViewController中

[英]IOS 5: Using Asset Object loaded in UITableView to display in another ViewController using StoryBoard

Edited: 编辑:

From my earlier question (below), I have a handle on my assets (video) and I also have an implementation of my PlayVideoViewController but I am stuck on how to pass this asset to the playVideoViewController object. 从前面的问题(如下)中,我可以处理资产(视频),也可以实现PlayVideoViewController的实现,但是在如何将资产传递给playVideoViewController对象方面,我还是很固执。 Here is a code snippet of the implementation: 这是实现的代码片段:

  • (void)viewDidLoad { [super viewDidLoad]; (void)viewDidLoad {[super viewDidLoad];

    1. ALAssetRepresentation *assetRepresentation = [asset defaultRepresentation]; ALAssetRepresentation * assetRepresentation = [资产defaultRepresentation];
    2. NSURL *URL = [assetRepresentation url]; NSURL * URL = [assetRepresentation url];
    3. NSLog(@"url: %@", URL ); NSLog(@“ URL:%@”,URL);

.... } ....}

In my line 1., it gives me a "Use of undeclared identifier 'asset'" error. 在我的第1行中,它给我一个“使用未声明的标识符'asset'”错误。 If I can pass 'asset' then I can resolve the issue but the only examples I have seen use .nib not storyboard so for example, using .NIB, the call is: PlayVideoViewController *playVideoViewController = [[PlayVideoViewController alloc ] initWithNibName:@"PlayVideoViewController" bundle:nil asset:asset]; 如果我可以通过“资产”,那么我可以解决问题,但是我看到的唯一示例使用.nib而不是情节提要,因此,例如,使用.NIB,该调用为:PlayVideoViewController * playVideoViewController = [[PlayVideoViewController alloc] initWithNibName:@“ PlayVideoViewController“捆绑包:零资产:资产]; Please help on how to pass the 'asset'. 请帮助如何通过“资产”。

== ==

I can't figure out just one thing and I hope someone can help me out. 我不能只解决一件事,希望有人能帮助我。 Please note I am not using a .nib but storyboards and that is why I am stuck here. 请注意,我不是使用.nib,而是使用情节提要,这就是为什么我被困在这里。

I have loaded assets (videos) into a tableview and when a user selects a tableviewcell, the app transitions to a new view controller (PlayVideoViewController) that just plays the video. 我已将资产(视频)加载到表视图中,并且当用户选择一个表单元时,应用程序将转换为仅播放视频的新视图控制器(PlayVideoViewController)。 From the class loading the asset (*asset) and letting the user select it, I have this code snippet: 从加载资产(*资产)并让用户选择的类中,我有以下代码片段:

ALAsset *asset = [assets objectAtIndex:row];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard.storyboard" bundle:nil];

PlayVideoViewController *playVideoViewController = [storyboard instantiateViewControllerWithIdentifier:@"PlayVideoViewController"];     
[self.navigationController pushViewController:playVideoViewController animated:YES ];

How do I pass the selected video to PlayVideoViewController so it just plays the video? 如何将选定的视频传递给PlayVideoViewController,使其仅播放视频? How so I incorporate that into my code and kindly show me an example? 我如何将其合并到我的代码中并请给我看一个示例?

Create a " @property " in your PlayVideoViewController's " .h " (interface) file that takes a file URL or some way to reference your video. 在PlayVideoViewController的“ .h ”(接口)文件中创建一个“ @property ”,该文件采用文件URL或某种方式引用您的视频。

Then, after you instantiate your playVideoViewController and before you push, simply set that property's value to the file URL so your new controller knows where to get the video from. 然后,在实例化playVideoViewController之后并在按下之前,只需将该属性的值设置为文件URL,以便新控制器知道从何处获取视频。

这可能会对其他人有所帮助:为了解决该问题,我只是在新的viewcontroller中创建了一个ALAsset对象,并将该对象传递给storyBoard:instantiateViewControllerWithIdentifier之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM