Tag: uicollectionview

UICollectionView滚动不顺畅。 为什么?

为什么我的UICollecionView的滚动不顺畅? 这是代码: static NSString *CellIdentifier = @"cellRecipe"; // Configure the cell… [cell setBackgroundColor: [UIColor colorWithPatternImage:[UIImage imageNamed:@"bgRecipeCell.png"]]]; cell.image.layer.masksToBounds = YES; cell.image.layer.cornerRadius = 8.0f; cell.image.layer.borderColor = [UIColor blackColor].CGColor; cell.image.layer.borderWidth = 1.0f; Recipes *recipe = [recipesArray_ objectAtIndex:indexPath.item]; //checking for purchase NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; NSObject *object = [prefs objectForKey:@"com.__.__.recipefree"]; if ([recipe.isPaid integerValue] == 0) { [cell.freeImage setHidden:NO]; […]

如何每秒更新UICollectionViewCell的UILabel(swift)

我有一个UICollectionViewCell与UILabel显示两个date之间的日差。 我想每秒更新一次。 我曾尝试使用NSTimer重新加载UICollectionview的数据,但它使得用户界面非常慢。 我如何去实现这个? 谢谢。

滚动时,collectionview更改单元格背景图像

嗨,我在我的应用程序中使用collectionview。 和它的工作,当我select任何细胞,我只是改变该单元格的背景图像。 但是当我滚动集合视图,更改背景图像自动更改为默认图像。 这是我的问题。 这是我的代码 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell : seat_cell = collectionView.dequeueReusableCellWithReuseIdentifier("seat_cell", forIndexPath: indexPath) as! seat_cell cell.backgroundView = UIImageView() let data : SeatDetailModel = get_seat_detail.objectAtIndex(indexPath.row) as! SeatDetailModel if (data.KoltukStr == "PI") || (data.KoltukStr == "MA") || (data.KoltukStr == "SA") || (data.KoltukStr == "KA") || (data.KoltukStr == "KO") […]

为什么UICollectionView与UICollectionViewFlowLayout不显示单元格,但要求大小?

为什么使用stream布局的collectionview有时不显示单元格,但是代表请求的大小,以及部分项目数和响应者提供正确的信息。 这里的例子,6节的麻烦 2015-04-08 04:43:59.020 ASKED SECTION:0 ITEMS:0 2015-04-08 04:43:59.023 RETUR SECTION:0 ITEMS:1 2015-04-08 04:43:59.023 ASKED SECTION:1 ITEMS:0 2015-04-08 04:43:59.024 RETUR SECTION:1 ITEMS:1 2015-04-08 04:43:59.024 ASKED SECTION:2 ITEMS:0 2015-04-08 04:43:59.024 RETUR SECTION:2 ITEMS:1 2015-04-08 04:43:59.024 ASKED SECTION:3 ITEMS:0 2015-04-08 04:43:59.024 RETUR SECTION:3 ITEMS:1 2015-04-08 04:43:59.025 ASKED SECTION:4 ITEMS:0 2015-04-08 04:43:59.043 RETUR SECTION:4 ITEMS:0 2015-04-08 04:43:59.043 ASKED […]

dequeueReusableSupplementaryViewOfKind崩溃在ios 7.1 – 索引0超出界限为空数组

具有2个部分的收集视图。 section 1: rows: 0 section 2: rows: 20 有像以下注册的网友: [self.collectionView registerNib:[UINib nibWithNibName:@"MissionDetailHeader" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MissionDetailHeader"]; [self.collectionView registerNib:[UINib nibWithNibName:@"MissionDetailHeaderPic" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"MissionDetailHeaderPic"]; 在ios8上完美工作 – 但在7.1上它总是在dequeueReusableSupplementaryViewOfKind上崩溃: – (UICollectionReusableView*)collectionView:(UICollectionView*)cv viewForSupplementaryElementOfKind:(NSString*)kind atIndexPath:(NSIndexPath*)indexPath { UICollectionReusableView* header; NSLog(@"LOAD SECT: %@", indexPath); if (indexPath.section == 0) { header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"MissionDetailHeaderPic" forIndexPath:indexPath]; } else { header = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"MissionDetailHeader" […]

出队后,自定义UICollectionViewCell属性为空

所以我有一个UICollectionView和一个自定义的单元格,这一切都显示出来,工作很好。 我在viewDidLoad中注册类: myCollectionView = [[UICollectionView alloc] initWithFrame:collectionViewFrame collectionViewLayout:layout]; [myCollectionView setDataSource:self]; [myCollectionView setDelegate:self]; [myCollectionView setBackgroundColor:[UIColor myColor]]; [myCollectionView registerClass:[SBCustomCell class] forCellWithReuseIdentifier:@"Cell"]; 在我的cellForItemAtIndexPath方法中,我将这个单元格出队并设置它的属性并返回它: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"Cell"; SBCustomCell *cell= [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; [cell setName: "My Name"]; cell.image = [UIImage imageNamed:@"lol.png"]; cell.score = 100.0; cell.backgroundColor=[UIColor whiteColor]; return cell; } 这一切工作正常,它显示在用户界面。 我的问题是,当我在collectionView上设置一个手势识别器,当我长按某个单元格时,我想能够访问它的属性。 […]

ios – Swift – dequeueReusableCellWithReuseIdentifier,collectionViewController的单元格(在UIView中)滚动后不会加载

我有一个ViewController 3视图: 标题(UIView) TabBar(UIView) UIView3(UIView) 在我的UIView3我有一个collectionViewController。 一个关键的因素是,我把我的collectionViewController.scrollEnable = False因为另一方面,当我滚动,只有UIView3滚动,我希望我entier屏幕滚动(这样,如果我们足够的滚动我的标题和Tabbar被隐藏。 所以这就是我所拥有的: 这就是我的屏幕的样子: 这是完美的。 但是 ,当我向下滚动时,这应该是这样的: 但是 ,看起来像这样: 我认为我的问题来自“dequeueReusableCellWithReuseIdentifier”函数,它没有看到我正在滚动,但我不知道如何“刷新”滚动值,因此它加载单元格3-4的末尾,也单元格5- 6。 你有什么主意吗 ?

将代码从cellForItemAtIndexPath传输到CollectionViewCell(parsing后端)

我正在使用Parse作为我的应用程序的数据库。 我想创build一个CollectionViewCell并将其代码转移到那里,而不是在View Controller的cellForItemAtIndexPath中。 我该怎么做呢? 谢谢。 – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { static NSString *identifier = @"productCell"; ProductCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; PFObject *product = [self.products objectAtIndex:indexPath.row]; NSString *price = [NSString stringWithFormat:@"$%@.00", product[@"price"]]; cell.price.text = price; PFFile *userImageFile = product[@"firstThumbnailFile"]; [userImageFile getDataInBackgroundWithBlock:^(NSData *imageData, NSError *error) { if (!error) { UIImage *thumbnailImage = [UIImage imageWithData:imageData]; […]

在UIImagePickerControllerclosures后,UICollectionView将不会reloadData()

我有一个小问题,从UIImagePickerControllerselect图像(并保存到parsing,因为我的UICollectionView从我的图像Parse填充),我的UICollectionView将不会加载新保存的图像,直到我离开该viewController并回到它。 我已经尝试了所有我能想到的工作。 我应该在哪里把我的代码保存和解散控制器? func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { let imagePicture = UIImageJPEGRepresentation(image, 0.1) let imageFile = PFFile(name: "imageFile.jpg", data: image) let saveImage = PFObject(className: "Gallery") saveImage["imageFile"] = imageFile saveImage["dogName"] = self.dogSelectedName saveImage["userID"] = PFUser.currentUser()?.objectId saveImage["dogID"] = self.dogObjectID saveImage.saveInBackgroundWithBlock { (Bool, error) -> Void in if error != nil { […]

UICollectionView:更改自定义单元格中的sizeForItemAtIndexPath

关于模型 – 视图 – 控制器(MVC)的一个非常基本的问题。 我有一个自定义UICollectionView填充自定义UICollectionViewCells 。 集合视图定义了UICollectionViewDelegateFlowLayout方法中的单元格的大小,即collectionView: sizeForItemAtIndexPath 。 同时,通过自定义收集单元视图控制器添加和删除子视图。 我的问题:当从单元格的视图控制器添加或删除子视图,我怎么也告诉集合视图控制器更改高度? 我明白委托和数据源的概念,但认为单元格是它自己的委托,所以当添加子视图时,如何将消息(“更改高度…”)从单元传递到集合视图控制器。去掉?