-1

Hi in this code the protocol RefreshLibraryDropBoxDelegate doesn't work, doesn't call the method refreshLibrary in the WVdALibraryDocumentViewController. Why?

WVdADropboxViewController.h:

#import <UIKit/UIKit.h>
#import <DropboxSDK/DropboxSDK.h>

@protocol RefreshLibraryDropBoxDelegate <NSObject>
@optional

-(void)refreshLibrary;

@end

@interface WVdADropboxViewController : UIViewController <DBRestClientDelegate, UITableViewDataSource, UITableViewDelegate>
{
id <RefreshLibraryDropBoxDelegate> delegate;
}

//delegate
@property (assign) id <RefreshLibraryDropBoxDelegate> delegate;

WVdADropboxViewController.m:

- (void)restClient:(DBRestClient *)client loadedFile:(NSString *)destPath
{
NSLog(@"upload complete");
[self.delegate refreshLibrary];
[[self navigationController]  popViewControllerAnimated:YES];
}

WVdALibraryDocumentViewController.h:

#import <UIKit/UIKit.h>
#import "WVdACustomCell.h"
#import "WVdAViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "WVdADropboxViewController.h"


@interface WVdALibraryDocumentViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate, RefreshLibraryDropBoxDelegate>
-(void)refreshLibrary;

WVdALibraryDocumentViewController.m:

// REFRESH LIBRARY //
-(void)refreshLibrary
{
     NSLog(@"refresh");
     [self getDataArrayDocumentFiles];
}
4

2 回答 2

1

你不需要这条线

{
id <RefreshLibraryDropBoxDelegate> delegate;
}

然后,在 WVdALibraryDocumentViewController

您需要在 viewDidLoad 或其他地方设置

WVdADropboxViewController *myCoolController = [WVdADropboxViewController new];
myCoolController.delegate = self;

它应该工作!

于 2013-09-08T09:39:13.243 回答
0

我猜你是为了在你的 WVdALibraryDocumentViewController.m 中设置委托。

在 WVdALibraryDocumentViewController 中的 viewDidLoad 中:

wVdADropboxViewController.delegate = self;
于 2013-09-08T09:36:22.553 回答