【发布时间】:2023-03-18 13:42:01
【问题描述】:
我有一个PSCollectionView,我用过一次。
现在我想在另一个ViewController 中再次使用它,但是当我开始实施它时,我到处都得到Duplicate interface definition for class 'PSCollectionView' 和Property has a previous declaration。我不知道该怎么做。
像这样:
self.waterflowView = [[PSCollectionView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
self.waterflowView.delegate = self; // This is for UIScrollViewDelegate
self.waterflowView.collectionViewDelegate = self;
self.waterflowView.collectionViewDataSource = self;
self.waterflowView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.waterflowView.delaysContentTouches = NO;
if ([[UIDevice currentDevice].model isEqualToString:@"iPhone"]) {
self.waterflowView.numColsPortrait = 1;
self.waterflowView.numColsLandscape = 2;
} else {
self.waterflowView.numColsPortrait = 1;
self.waterflowView.numColsLandscape = 2;
}
[self.mainView addSubview:waterflowView];
当我为我想要做的第二个 UIScrollView 添加此代码时
@interface KerkoViewController : UIViewController <UIScrollViewDelegate, PSCollectionViewDataSource, PSCollectionViewDelegate>
我在 PSCollectionView.h 文件中的这些行中遇到错误:
@interface PSCollectionView : UIScrollView
@property (nonatomic, strong) UIView *headerView;
@property (nonatomic, strong) UIView *footerView;
@property (nonatomic, assign, readonly) CGFloat colWidth;
@property (nonatomic, assign, readonly) NSInteger numCols;
@property (nonatomic, assign) NSInteger numColsLandscape;
@property (nonatomic, assign) NSInteger numColsPortrait;
@property (nonatomic, unsafe_unretained) id <PSCollectionViewDelegate> collectionViewDelegate;
@property (nonatomic, unsafe_unretained) id <PSCollectionViewDataSource> collectionViewDataSource;
和导入语句
#import <UIKit/UIKit.h>
#import "QuartzCore/QuartzCore.h"#include <mach/mach.h>
#include <mach/mach_time.h>
#include "PSCollectionView.h"
#import "WaterflowViewCell.h"
#import "MWPhotoBrowser.h"
【问题讨论】:
-
你如何'尝试再次使用它'?
-
我想在另一个 ViewController 中显示这个
PSCollectionView以及一些其他数据,并且在声明代表等时出现这些错误 -
你是如何在两个控制器中使用它的?
-
在此处粘贴您的代码...
-
向我们展示您的进口声明。
标签: ios uiscrollview