播放电影、音频并详细显示文件夹内容查看

发布于 2024-10-02 22:42:04 字数 475 浏览 0 评论 0原文

我有一个 tableView,其中列出了一个目录的内容,其中包括 jpg、pdf、zip、mp3、mp4、sql、.. 文件甚至文件夹。对于下一步,我有一个详细视图,它显示所选文件的一些属性,例如文件名、文件大小、文件路径、文件类型。一切都很完美。

但实际上我的计划是在详细视图中包含一个附加选项。

也就是说,

  1. 如果tableView中选择的文件是图像文件,则应该在detailView中打开一个imageView来显示该图像。
  2. 如果所选文件是 mp3,则应打开一个播放器在详细视图中播放该歌曲。
  3. 如果所选文件是视频或 mp4 文件,则应打开播放器以在详细视图中播放该视频。
  4. 如果所选项目是文件夹,则应再次打开一个显示文件夹内容的 tableView。
  5. 对于其他文件,它应该推送一个警报视图,表明它是未知文件。

希望我的概念得到了阐述。请帮助我继续一些示例代码。先感谢您..

I am having a tableView which lists the contents of a directory which includes jpg, pdf, zip, mp3, mp4, sql,.. files and even folders. For the next step, I am having a detailView which displays some properties of the selected file such as fileName, fileSize, filePath, fileType. Everything works perfect.

But actually my plan is to include a additional option in the detailView.

That is,

  1. If the selected file in the tableView is a image file, it should open a imageView in the detailView to display that image.
  2. If the selected file is a mp3, it should open a player to play the song in the detailView.
  3. If the selected file is a video or mp4 file, it should open a player to play that video in detailView.
  4. If the selected item is a folder, it should again open a tableView which dispalys the contents of the folder.
  5. For other files, it should push a alertView regarding that it is a unknown file.

Hope my concept was narrated. Please help me to proceed with some sample codes. Thank you in advance..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二智少女 2024-10-09 22:42:04

根据文件类型创建动态detailView、处理图像的控制器、处理视频的控制器等。

例如(参考Apple提供的Sample SplitViewController):

UIViewController <SubstitutableDetailViewController> *detailViewController = nil;

if("movie cell tapped"){
    MovieViewController *newDetailViewController = [[MovieViewController alloc] init];
    detailViewController = newDetailViewController;
}
if("image cell tapped"){
    ImageViewController *newDetailViewController = [[ImageViewController alloc] init];
    detailViewController = newDetailViewController;
}
/*  and so on   */


// Update the split view controller's view controllers array.
NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];
splitViewController.viewControllers = viewControllers;
[viewControllers release];

// Dismiss the popover if it's present.
if (popoverController != nil) {
    [popoverController dismissPopoverAnimated:NO];
}

// Configure the new view controller's popover button (after the view has been displayed and its toolbar/navigation bar has been created).
if (rootPopoverButtonItem != nil) {
    [detailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem];
}

[detailViewController release];

Create a dynamic detailView, a controller to handle images, a controller to handle video, etc. based on the file type.

For example (refer to the Sample SplitViewController provided by Apple):

UIViewController <SubstitutableDetailViewController> *detailViewController = nil;

if("movie cell tapped"){
    MovieViewController *newDetailViewController = [[MovieViewController alloc] init];
    detailViewController = newDetailViewController;
}
if("image cell tapped"){
    ImageViewController *newDetailViewController = [[ImageViewController alloc] init];
    detailViewController = newDetailViewController;
}
/*  and so on   */


// Update the split view controller's view controllers array.
NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];
splitViewController.viewControllers = viewControllers;
[viewControllers release];

// Dismiss the popover if it's present.
if (popoverController != nil) {
    [popoverController dismissPopoverAnimated:NO];
}

// Configure the new view controller's popover button (after the view has been displayed and its toolbar/navigation bar has been created).
if (rootPopoverButtonItem != nil) {
    [detailViewController showRootPopoverButtonItem:self.rootPopoverButtonItem];
}

[detailViewController release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文