我想UICollectionView
在同一页面上有两个.两个UICollectionView
将根据需要显示不同的数据.怎么做?先感谢您.
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifierHall2 = @"hall2";
/* Uncomment this block to use subclass-based cells */
timeCell *cell = (timeCell *)[myCollectionViewHall2 dequeueReusableCellWithReuseIdentifier:cellIdentifierHall2 forIndexPath:indexPath];
[cell.timeButton setTitle:[[allSimilarMutableArray valueForKey:@"showTime"] objectAtIndex:indexPath.item] forState:UIControlStateNormal];
return cell;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifierHall3 = @"hall3";
/* Uncomment this block to use subclass-based cells */
timeCell *cell = (timeCell *)[myCollectionViewHall3 dequeueReusableCellWithReuseIdentifier:cellIdentifierHall3 forIndexPath:indexPath];
[cell.timeButton setTitle:[[allSimilarMutableArray valueForKey:@"showTime"] objectAtIndex:indexPath.item] forState:UIControlStateNormal];
return cell;
}
Run Code Online (Sandbox Code Playgroud) 在 iOS 11 中,如果我们设置为隐藏,则在滚动 tableView 时 searchBar 会隐藏。向上滚动 collectionView 时如何隐藏 searchBar、navigationBar 和 tabBar?并在向下滚动时取消隐藏它们?谢谢你的帮助...
我有CollectionView
一个源自ObservableCollection
:
private static ObservableCollection<CalculationViewModel> _calculations;
CalculationViewModelsCollection = (CollectionView)CollectionViewSource.GetDefaultView(_calculations);
Run Code Online (Sandbox Code Playgroud)
我的问题是,当过滤器的结果是什么都没有时,我想清除过滤器,并用其他条件重新过滤,但CollectionView
总是空的。
我尝试通过以下方式重置过滤器:
CalculationViewModelsCollection.Filter = null;
CalculationViewModelsCollection.Refresh();
Run Code Online (Sandbox Code Playgroud)
和
CalculationViewModelsCollection.Filter = delegate(object p)
{
return true;
};
Run Code Online (Sandbox Code Playgroud)
但它们都不起作用。
您能否提供一些如何重置过滤器的建议CollectionView
?
我有一个故事板项目,我添加了PSTCollectionview类和所有文件.然后我为我的viewcontroller创建了一个类"allbooks.h,.m in"PSUICollectionviewcontroller_"并且iam无法在我的viewcontroller上添加这个类???
GMMAllBooksGrid.h
#import <UIKit/UIKit.h>
@interface GMMAllBooksGrid : PSUICollectionViewController
@end
Run Code Online (Sandbox Code Playgroud) 我有UICollectionView
2个部分.我想在用户点击它时选择单元格.
每次用户点击单元格时,我的代码都会正确运行,单元格会变小,并且会在其中显示复选标记(imageView
我将其添加为单元格的子视图).问题是如果我在第一部分点击一个单元格,它会在第二部分中选择另一个单元格.这很奇怪,因为我使用了indexPath
.
这是我的代码:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
// handle tap events
let cell = collectionView.cellForItemAtIndexPath(indexPath)
let centerCell = cell?.center
if cell!.frame.size.width == cellWidth {
cell?.frame.size.width = (cell?.frame.size.width)!/1.12
cell?.frame.size.height = (cell?.frame.size.height)!/1.12
cell?.center = centerCell!
let imageView = UIImageView()
imageView.image = MaterialIcon.check?.imageWithColor(MaterialColor.white)
imageView.backgroundColor = MaterialColor.blue.accent2
imageView.frame = CGRectMake(1, 1, 20, 20)
imageView.layer.cornerRadius = imageView.frame.height/2
imageView.clipsToBounds = true
if indexPath.section == 0 {
imageView.tag = indexPath.row+4000
} else {
imageView.tag = indexPath.row+5000
}
print("IMAGEVIEW …
Run Code Online (Sandbox Code Playgroud) 我在我的集合视图上启用了分页,并遇到了每次滑动的第一个问题,不是在不同的单元格上停止,而是在页面上停止。
然后我尝试在 ScrollViewWillEndDecelerating 中输入代码并手动处理分页。但是我的问题是更改集合视图 ContentOffset 或滚动到 Point 都不起作用,除非在 LayoutSubiews 中调用。这是它们影响 CollectionView 的唯一地方
我的集合视图中的每个单元格都是全屏的。我处理布局子视图中的单元格大小。
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if let layout = customCollectionView.collectionViewLayout as? UICollectionViewFlowLayout {
let itemWidth = view.frame.width
let itemHeight = view.frame.height
layout.itemSize = CGSize(width: itemWidth, height: itemHeight)
layout.invalidateLayout()
}
let ip = IndexPath(row: 2, section: 0)
view.layoutIfNeeded()
customCollectionView.scrollToItem(at: ip, at: UICollectionViewScrollPosition.centeredVertically, animated: true)
let point = CGPoint(x: 50, y: 600)
customCollectionView.setContentOffset(point, animated: true)
}
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
let pageHeight = …
Run Code Online (Sandbox Code Playgroud) 我得到了一个包含对象的数组,并用它们填充集合视图。例如,我的集合视图中有 3 个对象。有没有办法根据对象名称接收当前索引路径?
谢谢