我希望我的部分UICollectionView有一个带图像的标题.
我已按照以下步骤操作:
UICollectionViewUICollectionReusableView为它创建了一个子类ImageView标题附件ImageView中的自定义类创建了一个出口.hviewDidLoad:
[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)
我知道数据源和委托方法正在工作,因为我可以看到所有单元格及其部分.但是,我没有我的标题.我在上面的方法中设置了一个断点,它永远不会被调用.
我究竟做错了什么?
我有一个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)