I am having a tableView which lists the contents directory which includes jpg, pdf, zip, mp3, mp4, sql,.. files and even folders. In 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,
- If the selected file in the tableView is a image file, it should open a imageView in the detailView to display that image.
- If the selected file is a mp3, it should open a player to play the song in the detailView.
- If the selected file is a video or mp4 file, it should open a player to play that video in detailView.
- If the selected item is a folder, it should again open a tableView which dispalys the contents of the folder.
- For other files, it should push a alertView regarding that it is a unknown file.
Hope my concept was narrated well. I got the methods for playing the .mp3 and .mp4 files. Now I am stuck in pushing the imageView and in case of a folder. I have no ideas to proceed both the methods.
This is my tableView

This is my detailView for video file

This is my detailView for a .mp3 file

This is the detailView left empty for my imageView.

Please help me to proceed with some sample codes. Thank you in advance.
Judging by your screenshots and progress of implementing the other filetypes, I assume you are able to pass the information of the file path to the detail view. So, for the image file, I am going to discuss how to display it into a
UIImageView.For the image view, You will want create a
UIImagewith the path.Code example below: Assume that
pathStringis anNSString*with the image path, and thatimageViewis now aUIImageViewwhich should display the image. This code would reside in the-viewDidLoadmethod of thedetailViewControllerhandling the image display.As for the folder view, this is a bit different. For the best result you will want to recursively load the
tableViewControlleryou are using to display the list of files now (so that it will inherit all the file/folder handling recursively).I would suggest to add an instance variable like
folderPathto thetableViewControllerthat you set before actually pushing the view. And thetableViewControllershould use this as the base path.Code example below: Assume that
pathStringis anNSString*with the destination path, and thatdetailViewControlleris now an instance of the newtableViewControllerto be opened. This code would reside in the method that will create the newdetailViewControllerto be displayed, somewhere withintableView:didSelectRowAtIndexPath:You should then implement in the
-viewDidLoadmethod of thetableViewController, on what folder content should be read from thefolderPathinstance variable.