简体   繁体   English

如何在UICollectionviewcontroller中显示文本字段?

[英]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.

相关问题 如何将UISearchDisplayController与UICollectionViewController一起使用? - How can I use UISearchDisplayController with UICollectionViewController? 如何在 UICollectionViewController 的标头中访问 UISegmentedControl? - How can I access UISegmentedControl in header of UICollectionViewController? 如何实现从UICollectionViewController到UIViewController的自定义UIViewController转换? - How can I achieve this custom UIViewController Transition from UICollectionViewController to UIViewController? 如何创建一个转接表单 UIViewController 到 UICollectionViewController? - 以编程方式 - How can I create a segue form UIViewController to UICollectionViewController ? - Programmatically 我如何使datePicker在textField上显示日期? - How can i make a datePicker show the date on a textField? 我可以在一个应用程序中集成UIViewController和UICollectionViewController吗? - Can I integrate UIViewController and UICollectionViewController in one app? 我们如何决定使用 UICollectionViewController 还是 UIViewController? - How can we decide to use UICollectionViewController or UIViewController? 如何在UIContainerView中连接UICollectionViewController - How do I hook up UICollectionViewController in UIContainerView 如何在 UICollectionViewCell 内的 UITableView 之间同步滚动(在 UICollectionViewController 内) - How can I synchronise the scrolling between a UITableView inside of a UICollectionViewCell (Inside a UICollectionViewController) 如何使用可表示协议在SwiftUI中显示UICollectionViewController? - How to show an UICollectionViewController inside SwiftUI using representable protocol?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM