Objective c 子类集合视图:执行被中断,原因:试图取消引用无效的ObjC对象
我刚刚在集合视图单元格中实现了一个集合视图作为属性Objective c 子类集合视图:执行被中断,原因:试图取消引用无效的ObjC对象,objective-c,uicollectionview,unrecognized-selector,Objective C,Uicollectionview,Unrecognized Selector,我刚刚在集合视图单元格中实现了一个集合视图作为属性 #import <UIKit/UIKit.h> #import "EMSubCollectionView.h" @interface EMYearCell : UICollectionViewCell -(void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource>)dataSourceDelegate index:(NSIntege
#import <UIKit/UIKit.h>
#import "EMSubCollectionView.h"
@interface EMYearCell : UICollectionViewCell
-(void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource>)dataSourceDelegate index:(NSInteger)index currentSection:(NSInteger)section;
@property (strong, nonatomic) IBOutlet EMSubCollectionView *collectionView;
@property (strong, nonatomic) IBOutlet UILabel *monthHeader;
@end
#导入
#导入“EMSubCollectionView.h”
@接口EMYearCell:UICollectionViewCell
-(void)setCollectionViewDataSourceDelegate:(id)dataSourceDelegate索引:(NSInteger)索引currentSection:(NSInteger)节;
@属性(强,非原子)IBEMSubCollectionView*collectionView;
@属性(强,非原子)IBUILabel*monthHeader;
@结束
我的实现中的方法如下所示:
-(void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource>)dataSourceDelegate index:(NSInteger)index currentSection:(NSInteger)section
{
self.collectionView.dataSource = dataSourceDelegate;
self.collectionView.tag = index;
self.collectionView.numberOfCurrentSection = section;
[self.collectionView reloadData];
}
-(void)setCollectionViewDataSourceDelegate:(id)dataSourceDelegate索引:(NSInteger)索引currentSection:(NSInteger)节
{
self.collectionView.dataSource=dataSourceDelegate;
self.collectionView.tag=索引;
self.collectionView.numberOfCurrentSection=节;
[self.collectionView-reloadData];
}
我只是想给我的集合视图第二个“标记属性”,所以我将相应的collectionview属性子类化:
#import <UIKit/UIKit.h>
@interface EMSubCollectionView : UICollectionView
@property NSInteger numberOfCurrentSection;
@end
#导入
@接口EMSubCollectionView:UICollectionView
@属性NSInteger numberOfCurrentSection;
@结束
当我运行我的应用程序时,它立即崩溃:
我的代码有什么问题?提前感谢。解决方案非常简单:我只是忘了将新类分配给故事板中相应的集合视图。现在,一切都很有魅力。解决方案非常简单:我只是忘了将新类分配给我的故事板中相应的集合视图。现在,一切都很有魅力。解决方案非常简单:我只是忘了将新类分配给我的故事板中相应的集合视图。现在,一切都很有魅力。解决方案非常简单:我只是忘了将新类分配给我的故事板中相应的集合视图。现在一切都像一个魔咒