小编Ede*_* V.的帖子

未调用UICollectionReusableView方法

我希望我的部分UICollectionView有一个带图像的标题.

我已按照以下步骤操作:

  • 在故事板上,为我的分配了一个标题作为附件 UICollectionView
  • 给了它一个标识符
  • UICollectionReusableView为它创建了一个子类
  • 将自定义类分配给故事板上的类.
  • 放在ImageView标题附件
  • 为文件ImageView中的自定义类创建了一个出口.h
  • 在以下位置实施以下内容viewDidLoad:

 

[self.collectionView registerClass:[ScheduleHeaderView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerIdentifier];

-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    UICollectionReusableView *reusableview = nil;

    if (kind == UICollectionElementKindSectionHeader)
    {
        ScheduleHeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:headerIdentifier forIndexPath:indexPath];

        headerView.headerImageView.image = [UIImage imageNamed:@"blah.png"];

        reusableview = headerView;
    }

    return reusableview;
}
Run Code Online (Sandbox Code Playgroud)

我知道数据源和委托方法正在工作,因为我可以看到所有单元格及其部分.但是,我没有我的标题.我在上面的方法中设置了一个断点,它永远不会被调用.

我究竟做错了什么?

ios uicollectionview

69
推荐指数
6
解决办法
4万
查看次数

在循环目标-c中追加字符串

我有一个for-in循环运行未知的次数,当它完成运行时我希望所有名称都附加如下:name1, name2,name3依此类推.

如何在循环中追加字符串?

我在考虑这样的事情:

if (donePressed)
{
    NSString *allFriends;
    selectedFriends = friendPicker.selection;
    for (NSDictionary * friend in selectedFriends)
    {
        NSString * friendName = [friend objectForKey:@"name"];
        // some built-in method that appends friendName to allFriends with a ", " between them
    }

    NSLog(@"%@",selectedFriends);
}
Run Code Online (Sandbox Code Playgroud)

objective-c nsstring

1
推荐指数
1
解决办法
1503
查看次数

标签 统计

ios ×1

nsstring ×1

objective-c ×1

uicollectionview ×1