まず、戻るボタンのアクション メソッドを変更します。戻るボタンはスタックから最後のビューをポップするため、場合によっては機能しない可能性があります。また、次のボタンを追加します (または、適切に動作する didselect 行を使用します)。
次に、singleton クラスを使用してフォルダー パスを保持します。
次に、詳細フォルダーをメタデータ パスに追加しselected folder/detail folder
、最後のパスを削除します。selected folder/
コードに singleton を 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
-(void)loadView:
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
}
次に、クライアントを呼び出すだけです
[[self restClient] loadMetadata:destDirectory];
この呼び出しはテストされていないことに注意してください。いくつかのタイプミスが見られ、コードを少し編集する必要があるかもしれません