您好在此代码中协议RefreshLibraryDropBoxDelegate
不起作用,不会调用WVdALibraryDocumentViewController
中的方法refreshLibrary。为什么呢?
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];
}
答案 0 :(得分:1)
您不需要此行
{
id <RefreshLibraryDropBoxDelegate> delegate;
}
然后,在WVdALibraryDocumentViewController
中您需要在viewDidLoad或其他地方设置
WVdADropboxViewController *myCoolController = [WVdADropboxViewController new];
myCoolController.delegate = self;
它应该工作!
答案 1 :(得分:0)
我想你可以在WVdALibraryDocumentViewController.m中设置委托。
在WVdALibraryDocumentViewController中的viewDidLoad中:
wVdADropboxViewController.delegate = self;