[英]How can I show the textfield in the UICollectionviewcontroller?
我检查了xcode中的页眉节和页脚节,我在UIcollectionviewcontroller中的该页眉中添加了一个文本字段 ,但是当应用运行时,它没有显示文本字段 ?为什么?
you should subclass UICollectionReusableView, add your outlet to the subclass, modify the reuse identifier of the header view in the storyboard and implement collectionView:viewForSupplementaryViewOfKind:atIndexPath from the datasource. 您应该将UICollectionReusableView子类化,将出口添加到子类中,在情节提要中修改标题视图的重用标识符,并从数据源实现collectionView:viewForSupplementaryViewOfKind:atIndexPath。 check the apple documentation. 查看Apple文档。
for example: 例如:
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
HeaderView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView" forIndexPath:indexPath];
//set the delegate of the textfield to the view controller
headerView.textField.delegate = self;
return headerView;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.