【发布时间】:2016-11-03 07:10:24
【问题描述】:
我一直在开发一个使用集合视图的应用程序,并且我正在创建一个自定义视图单元格(类别视图单元格),它是 UICollectionViewCell 的子类。我还想创建自定义视图单元(LinkCell)的子类。我已经搜索了一段时间,但找不到为什么会出现错误“找不到 'CategoryViewCell' 的接口声明,'LinkCell' 的超类”
//CategoryViewCell.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
@class ViewController;
@interface CategoryViewCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *image;
@property (nonatomic) ViewController *parentView;
@property (nonatomic) NSString *cellName;
@end
//CategoryViewCell.m
#import "CategoryViewCell.h"
@implementation CategoryViewCell
@end
//LinkCell.h
#import <UIKit/UIKit.h>
#import "CategoryViewCell.h"
#import "PJP Webview.h"
@interface LinkCell : CategoryViewCell //Error here
@property (nonatomic) NSString *username;
@property (nonatomic) NSString *password;
@property (nonatomic) NSString *urlToLink;
@property (nonatomic) NSString *urlToLinkS;
@property (nonatomic) NSString *urlToLinkP;
@property (nonatomic) NSString *urlToLinkT;
@property (nonatomic) NSString *body;
-(IBAction)celltapped:(id)sender;
@end
//LinkCell.m
#import "LinkCell.h"
@implementation LinkCell
@synthesize urlToLink, username, password, image, cellName, parentView;
-(IBAction)celltapped:(id)sender {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *launchString = [NSString stringWithFormat:@"hasLaunched%@Before", self.cellName];
BOOL hasLaunchedCellBefore = [userDefaults boolForKey:launchString];
if (!hasLaunchedCellBefore) {
// first time launch code
hasLaunchedCellBefore = TRUE;
[userDefaults setBool:hasLaunchedCellBefore forKey:launchString];
[userDefaults synchronize];
PJP_Webview *vc = [parentView.storyboard instantiateViewControllerWithIdentifier:@"vc"];
vc.currentCell = self;
[parentView presentViewController:vc animated:YES completion:nil];
}
else {
}
}
@end
谁能告诉我我的错误在哪里?
【问题讨论】:
-
您是否尝试过清理项目文件夹(cmd+shift+k)?然后再次构建。
-
@Joshua,是的,我有,当我清理它时,错误消失了,但是一旦我构建它,错误就会回来
标签: ios objective-c inheritance subclass superclass