Tag: uicollectionview

UICollectionviewCellanimation

我想animation的collectionview单元格,animation应该是这样的: 第一个单元出现,然后延迟一段时间后, 第二个单元将出现一些animation ,这将继续像所有的单元格一样。 如何做到这一点?

UICollectionViewFlowLayout minimumLineSpacing不适用于整个集合视图 – Swift

我正在为日历创buildUIView子类,其中带有stream布局的UICollectionView用于显示date。 代码是: override func draw(_ rect: CGRect) { super.draw(rect) . . configureCalendarView() . } func configureCalendarView() { cellWd = Double(self.frame.size.width)/7.0 let layout = UICollectionViewFlowLayout.init() layout.minimumLineSpacing = 0.5 layout.minimumInteritemSpacing = 0.0 layout.sectionInset = UIEdgeInsetsMake(1, 0, 0, 0) collectionV = UICollectionView.init(frame: CGRect(x: 0, y:90, width:self.frame.size.width, height:CGFloat(cellWd * 5 + 3.5)), collectionViewLayout: layout) collectionV?.backgroundColor = self.backgroundColor collectionV?.isScrollEnabled = […]

删除子视图,然后将其添加回来

我有一个渐变子视图的UICollectionViewCell 。 在我的视图控制器,我有buttonsortingCoreData,然后在UICollectionView reloadData() 。 为了避免我的渐变子视图被一次又一次地绘制(就像它发生在过去一样),我在prepareForReuse()实现了removeFromSuperview() prepareForReuse() 。 在那里,我还实现了一个标志,以跟踪渐变的存在,所以当单元格加载时,我仍然添加一个新的渐变。 但是在删除渐变后,我的willMove(toSuperview: )不起作用,并且不显示渐变视图。 我的逻辑有什么问题? class CollectionCell: UICollectionViewCell { @IBOutlet weak var mealImg: UIImageView! @IBOutlet weak var mealTitleLbl: UILabel! @IBOutlet weak var gradientView: UIView! var gradientWasRemoved = false func configureCell(meal: Meal) { mealTitleLbl.text = meal.title let img = meal.getMealImage() mealImg.image = img addGradient() } func addGradient () { […]

在批量更新过程中重复单元格animation

我已经build立了一个collectionView, 通过这里的解决scheme来实现自定义的重新sorting行为 但是,当单元格被快速拖动到新行时,animation会再次显示拖动单元格的原始位置(请参见下文): 我想知道如何才能把拖动的单元格放在被拖动的那一行上,而不是再次显示它的原始单元格的animation。

PFObject比较:选项:searchparse.com类时出现范围错误

我试图通过UISearchBar在我的集合视图中从Parse.com类进行search查询。 当我尝试search它崩溃,并给我下面的错误。 有没有更好的方法来做一个searchfunction的集合视图,如果没有,我做错了什么? Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PFObject compare:options:range:]: unrecognized selector sent to instance 0x1741366c0' 代码如下: @implementation DiscoverViewController – (void)viewDidLoad { [super viewDidLoad]; filteredContentList = [[NSMutableArray alloc] init]; [self fetchFeatured]; _featured = [[NSMutableArray alloc] initWithCapacity:1000]; } – (void)fetchFeatured { PFQuery *query = [PFQuery queryWithClassName:@"Featured"]; [query findObjectsInBackgroundWithBlock:^(NSArray *posts, NSError *error) { if […]

使用UICollectionView和NSFetchedResultsController不保存

我在github上使用项目查找,让我使用UICollectionView和UICollectionView ,项目是这样的 在我的项目中,我有一个核心数据与两个实体, Element和Document , Element和Document之间有一对多的关系,所以一个Element可以有更多的Document ,但一个Document只能有一个Element ,然后我这样做AppDelegate : – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. ElementViewController *elementView = [[ElementViewController alloc] initWithNibName:@"ElementViewController" bundle:nil]; elementView.managedObjectContext = self.managedObjectContext; DocumentViewController *documentView = [[DocumentViewController alloc] initWithNibName:@"DocumentViewController" bundle:nil]; documentView.managedObjectContext = self.managedObjectContext; elementView.documentView = documentView; UINavigationController *navController […]

几个UICollectionViews像iBooks一样水平滚动

我想做一个包含几个collectionViews的视图。 向左或向右滑动将滚动到另一个collectionView 。 作为启用分页的第一步,我添加了一个scrollView 。 我也将内容大小设置为页数。 int nb_of_items = 10; // Scroll view for (int i=0; i< nb_of_items ; i++) { CGRect frame = CGRectMake(_scrollView.frame.size.width * i, 0, _scrollView.frame.size.width, _scrollView.frame.size.height); _collectionView.frame = frame; [_scrollView addSubview:_collectionView]; } _scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width * nb_of_items, _scrollView.frame.size.height); _scrollView.delegate = self; collectionView是在我的故事板中定义的,并将数据源和委托设置为self。 我只收到第一页上的collections。 在其他页面上,我什么也得不到 。 当scrollView减速时,我也尝试刷新收集 – (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self […]

编程创build一个uicollectionview时使用自定义的init方法

由于故事板的限制,我正在编程创build一个UICollectionView。 这工作都很好,当我想添加一个UICollectionViewCell我做到以下几点: [collectionView registerClass:[Cell class] forCellWithReuseIdentifier:@"ID"]; 我想知道的是如何使用类“Cell”中的自定义init方法,因为我不能做如下的事情: [collectionView registerClass:[[Cell class]init_custom]forCellWithReuseIdentifier:@"ID"]; 问题:如何使用自定义UICollectionViewCell类中的自定义init方法?

dynamic加载UICollectionView数据源

我有一个加载UICollectionView的问题。 数据源是一个数组。 该数组可能包含多达10k个元素。 转换完成后,在数组中创build对象花费了大量的时间。 我不知道是否正确的方式加载数组最初与n(<< 10k)元素,并添加滚动时的对象。 任何build议真的会有所帮助。 谢谢

UICollectionViewFlowLayout子类有时会在iOS6上崩溃

我想要一个UICollectionViewstream动布局方向是水平的。 我已经实现了方法targetContentOffsetForProposedContentOffset:withScrollingVelocity:当在表格中滚动时总是将视图“捕捉”到集合视图中的单元格。 我已经这样subclassed UICollectionViewFlowLayout(与我的实现方法的代码从这里: targetContentOffsetForProposedContentOffset:withScrollingVelocity没有inheritanceUICollectionViewFlowLayout ) @implementation SnappingFlowLayout -(id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if(self) { [self customInit]; } return self; } -(void)customInit { // self.itemSize = CGSizeMake(75.0, 75.0); self.minimumInteritemSpacing = 0; self.minimumLineSpacing = 0; self.scrollDirection = UICollectionViewScrollDirectionHorizontal; self.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); } – (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity { CGFloat offsetAdjustment = MAXFLOAT; CGFloat […]