如何在ios5上为我的文件浏览器项目使用故事板?

如何在ios5上为我的文件浏览器项目使用故事板?,ios5,dropbox,Ios5,Dropbox,我正试图找到一种通过使用故事板浏览远程文件系统(dropbox)的解决方案。例如,如果用户点击浏览文件夹,则没有关于文件夹结构深度的信息。我的意思是,文件夹可能包含另一个文件夹,另一个文件夹可能包含另一个文件夹,它可以转到5、10、20等等。这使得无法定义我应该添加多少个tableview控制器。我尝试只使用一个,并使用以下代码为每个选定文件夹更新了相同的tableview: - (void)tableView:(UITableView *)tableView didSelectRowAtInd

我正试图找到一种通过使用故事板浏览远程文件系统(dropbox)的解决方案。例如,如果用户点击浏览文件夹,则没有关于文件夹结构深度的信息。我的意思是,文件夹可能包含另一个文件夹,另一个文件夹可能包含另一个文件夹,它可以转到5、10、20等等。这使得无法定义我应该添加多少个tableview控制器。我尝试只使用一个,并使用以下代码为每个选定文件夹更新了相同的tableview:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
[dropBoxArray removeAllObjects]; //remove all the objects which comes from the previous folder structure

[[self restClient] loadMetadata:@"/selected folder/"]; // load the newly selected folder contents
}
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(nsindepath*)indepath
{
[dropBoxArray removeAllObjects];//删除来自上一个文件夹结构的所有对象

[[self-restClient]loadMetadata:@/选定文件夹/“];//加载新选定的文件夹 目录
它只适用于一个方向,用户可以永远浏览文件夹树,但这一次不可能一步一步地返回。因为导航控制器将后退按钮放在导航项上,并加载上一个视图而不是上一个目录。
我找不到如何正确处理此逻辑并需要帮助。

首先更改后退按钮的操作方法,后退按钮从堆栈中弹出最后一个视图,这样它可能在您的情况下不起作用,并添加下一个按钮(或使用didselect row,无论对您有效)

其次,使用singleton类保留文件夹路径

因此,下一步将添加一个细节文件夹到元数据路径
selected folder/detail folder
,后面将删除最后一个路径
selected folder/

将singleton类添加到代码中:

#import <Foundation/Foundation.h>
@interface SingletonClass : NSObject
{
    NSString *lastCreatedFolderName;
    NSMutableArray *fileListForEdit;
}
@property (nonatomic, retain) NSString *lastCreatedFolderName;
@property (nonatomic, retain) NSMutableArray *fileListForEdit;
+ (SingletonClass *)sharedInstance;

@end

    #import "SingletonClass.h"

    @implementation SingletonClass

    @synthesize lastCreatedFolderName=_lastCreatedFolderName;
    @synthesize fileListForEdit=_fileListForEdit;

    + (SingletonClass *)sharedInstance
    {
        static SingletonClass *sharedInstance = nil;
        static dispatch_once_t onceToken;
        dispatch_once(&onceToken, ^{
            sharedInstance = [[SingletonClass alloc] init];
            // Do any other initialisation stuff here
        });
        return sharedInstance;
    }

    - (id)init {
        if (self = [super init]) {
            _lastCreatedFolderName = @"Empty Folder";
            _fileListForEdit=[[NSMutableArray alloc]init];

        }
        return self;
    }
  -(NSString *) addFolderPath : (NSString *) nextFolder{


    [_fileListForEdit addObject:nextFolder]; // add your folder path to mutablearray 
    for(int i=0 ; int<[_fileListForEdit count]; i++) {
         _lastCreatedFolderName=[NSString stringWithFormat:@"%@/%@",_lastCreatedFolderName,[_fileListForEdit objectAtIndex:i]]; //add folder path to your current path

     }

     return _lastCreatedFolderName;
} 
-(NSString *) removeLastFolderDromPath
{
     [_fileListForEdit removeLastObject];// remove last folder path from array

     //create new folder path
     for(int i=0 ; int<[_fileListForEdit count]; i++) {
         _lastCreatedFolderName=[NSString stringWithFormat:@"%@/%@",_lastCreatedFolderName,[_fileListForEdit objectAtIndex:i]]; //add folder path to your current path

     }

     return _lastCreatedFolderName;
}


    @end
那就给你的客户打个电话

[[self-restClient]加载元数据:destDirectory]

请注意,此调用未经测试。您可能会看到一些打字错误,需要稍微编辑代码

UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStyleBordered target:self action:@selector(backPressed:)];
self.navigationItem.leftBarButtonItem = btn;

   UIBarButtonItem *btnNext = [[UIBarButtonItem alloc] initWithTitle:@"next" style:UIBarButtonItemStyleBordered target:self action:@selector(nextPressed:)];
self.navigationItem.rightBarButtonItem = btnNext;

-(void)backPressed: (id)sender
{
    //call your singleton here and load last path
    SingletonClass *sharedInstance=[SingletonClass sharedInstance];
    NSString *destDirectory= [sharedInstance addFolderPath :@"nextFolder"];

}
 -(void)nextPressed: (id)sender
{
  //call your singleton here and load last path
  //get last created file name from singleton
    SingletonClass *sharedInstance=[SingletonClass sharedInstance];
    NSString *destDirectory= [sharedInstance removeLastFolderDromPath];//gives you the new path
}