开发者

Play movie, audio and display contents of a folder in detailView

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开发者_JAVA百科, 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..


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜