Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 折叠集合视图单元格_Objective C_Uiscrollview_Uicollectionview - Fatal编程技术网

Objective c 折叠集合视图单元格

Objective c 折叠集合视图单元格,objective-c,uiscrollview,uicollectionview,Objective C,Uiscrollview,Uicollectionview,我有一个滚动视图,在集合视图单元格中。滚动视图有自己的类(ClassA),集合视图也有自己的类(ClassB)。轻触索引行时,它将展开。甜心,很好用。唯一的问题是,您必须点击索引行来折叠单元格。由于单元中有一个UIScrollView,点击它不会使单元崩溃。所以,我所做的就是在滚动视图中创建点击检测。然后,点击检测选择器通过通知处理单元格的折叠: A类: - (void)singleTap:(UITapGestureRecognizer *)gesture { // Post a not

我有一个滚动视图,在集合视图单元格中。滚动视图有自己的类(ClassA),集合视图也有自己的类(ClassB)。轻触索引行时,它将展开。甜心,很好用。唯一的问题是,您必须点击索引行来折叠单元格。由于单元中有一个UIScrollView,点击它不会使单元崩溃。所以,我所做的就是在滚动视图中创建点击检测。然后,点击检测选择器通过通知处理单元格的折叠:

A类:

- (void)singleTap:(UITapGestureRecognizer *)gesture {
    // Post a notification to collapse
     [[NSNotificationCenter defaultCenter] postNotificationName:@"collapseCell" object:nil];
}
B类:

-(void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                          selector:@selector(deselectItemAtIndexPath:animated:)
                                          name:@"collapseCell" object:nil];
}

错误:“NSInvalidArgumentException”,原因:“-[CollectionViewController取消项目索引路径:动画:]:发送到实例0x7caa的无法识别的选择器,
NSNotification
未执行您认为它正在执行的操作。它没有调用或试图调用
UICollectionView
的委托方法,
取消项目索引路径:动画:
。它实际上在寻找一个不同的方法,但与
UICollectionView
s委托方法具有相同的签名


制作一个测试方法,称之为简单的方法,看看它是否能证实我所认为的正在发生的事情

有趣的。。。现在制定一个测试方法。是的,它要求我的测试方法很好。如何让它调用集合视图的委托方法?在您的测试方法中,调用集合视图的委托方法?我将如何做,如“
[collectionView deselectItemAtIndexPath:currentlySelectedIndexPath animated:YES];
”?显然,集合视图甚至没有出口(处理松散的代码)。。。[自收集视图取消项目索引路径:currentlySelectedIndexPath];如果不是。。然后[self.collectionView collectionView取消项目索引路径:currentlySelectedIndexPath]