Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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
Ios 当[UICollectionView reloadData]位于UITableViewCell内时,如何调用它?_Ios_Objective C_Uitableview_Uicollectionview - Fatal编程技术网

Ios 当[UICollectionView reloadData]位于UITableViewCell内时,如何调用它?

Ios 当[UICollectionView reloadData]位于UITableViewCell内时,如何调用它?,ios,objective-c,uitableview,uicollectionview,Ios,Objective C,Uitableview,Uicollectionview,我有一个UITableView,里面有一个UICollectionView。我假设在调用[UITableView reloadData]时,collectionView数据也会被重新加载,但事实并非如此 所发生的事情是加载tableview和collectionView,并从名为placesArray的数组中加载信息。但是,当我执行一个查询,并且placesArray发生更改时,我调用Tableview上的reloadData,但是不再调用collectionView委托方法 我使用的是源自教程

我有一个UITableView,里面有一个UICollectionView。我假设在调用[UITableView reloadData]时,collectionView数据也会被重新加载,但事实并非如此

所发生的事情是加载tableview和collectionView,并从名为placesArray的数组中加载信息。但是,当我执行一个查询,并且placesArray发生更改时,我调用Tableview上的reloadData,但是不再调用collectionView委托方法

我使用的是源自教程的AFTableViewCell

这就是AFTableviewCell.h的外观:

@interface AFIndexedCollectionView : UICollectionView

@property (nonatomic, strong) NSIndexPath *indexPath;

@end

static NSString *CollectionViewCellIdentifier = @"CollectionViewCellIdentifier";

@interface AFTableViewCell : UITableViewCell

@property (nonatomic, strong) AFIndexedCollectionView *collectionView;

- (void)setCollectionViewDataSourceDelegate:(id<UICollectionViewDataSource, UICollectionViewDelegate>)dataSourceDelegate indexPath:(NSIndexPath *)indexPath;

@end
集合视图方法

-(NSInteger)collectionView:(AFIndexedCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return placesArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CollectionViewCellIdentifier forIndexPath:indexPath];
//// Setting up the cell here
        return cell;
我还尝试在tableView委托方法中调用[cell.collectionView reloadData],但没有成功

我希望你能帮忙


谢谢-Shayne

添加viewcontroller数据源方法。@ArunAmmannaya添加了这些方法
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"FeaturedCell";
    
    AFTableViewCell *cell = (AFTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    if (!cell == YES)
    {
        cell = [[AFTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(AFTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
        [cell setCollectionViewDataSourceDelegate:self indexPath:indexPath];
        cell.collectionView.tag = indexPath.section;
        NSInteger index = cell.collectionView.tag;
        CGFloat horizontalOffset = [self.contentOffsetDictionary[[@(index) stringValue]] floatValue];
        [cell.collectionView setContentOffset:CGPointMake(horizontalOffset, 0)];
        cell.collectionView.tag = indexPath.section;
}
-(NSInteger)collectionView:(AFIndexedCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return placesArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CollectionViewCellIdentifier forIndexPath:indexPath];
//// Setting up the cell here
        return cell;