在对象上找不到属性'委托'

时间:2013-03-10 18:11:16

标签: ios objective-c xcode delegates

所以这是我的WSWordlistTableView.h:

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

@interface WSWordlistTableView : UITableView {

}

@property (nonatomic, assign) id <UITableViewDataSource>    datasource;
@property (nonatomic, assign) id <UITableViewDelegate>      delegate;

- (id)initWithFrame:(CGRect)frame;

@end

如您所见,有delegatedatasource属性。

我的WSWordlistTableViewController.h:

#import <UIKit/UIKit.h>
#import "WSWordlistManager.h"
#import "WSUserManager.h"

@interface WSWordlistTableViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource>

@end

所以,我正在构建一个滑动抽屉视图,这个表滑过主VC。这是主VC中创建视图和控制器然后将它们滑动到屏幕上的方法:

- (IBAction)slideWordlistView:(id)sender {

    if(!self.wordlistTableView ) {
       CGRect frame = CGRectMake(30, 340, 100, 310);
       self.wordlistTableView = [[WSWordlistTableView alloc] initWithFrame:frame];
    }      
    [self.view bringSubviewToFront:self.wordlistTableView];

    if(!self.wordlistTableViewController) {
       self.wordlistTableViewController = [[WSWordlistTableViewController alloc] init];
    }
    self.wordlistTableViewController.view.frame = self.wordlistTableView.bounds;
    self.wordlistTableViewController.view.autoresizingMask = self.wordlistTableView.autoresizingMask;
    [self addChildViewController:self.wordlistTableViewController];
    [self.wordlistTableView addSubview:self.wordlistTableViewController.view];
    [self.wordlistTableViewController didMoveToParentViewController:self];


    // *** THESE LINES THROW THE ERRORS
    self.wordlistTableView.delegate = self.wordlistTableViewController;
    self.wordlistTableView.datasource = self.wordlistTableViewController;


    CGFloat newX = kVisibleX;
    NSLog(@"newX = %f", newX);
    [UIView animateWithDuration: .25
                     animations:
     ^{
         CGRect drawerFrame = self.wordlistTableView.frame;
         drawerFrame.origin.x = newX;
         self.wordlistTableView.frame = drawerFrame;
     }];

}

self.wordlistTableView.delegate = self.wordlistTableViewController;
self.wordlistTableView.datasource = self.wordlistTableViewController;

这两行都抛出错误,说他们找不到'WSWordlistTableView *'上的属性'delegate'和'datasource'。他们都在那里。我不明白。

0 个答案:

没有答案
相关问题