Tag: uicollectionview

在UICollectionView Parse.com中显示parsing图像

林新的ios编程,所以感谢您的耐心。 我正在创build一个包含从parse.com后端下载的图像和标签的集合视图。 我能够在集合视图中完美显示标签,现在我正在尝试获取相应的图像。 我不确定如何去做。 请帮助SOS 这是我的function // Get Brands func getBrand () { // Create PFQuery var query:PFQuery = PFQuery(className: "BrandInfo") // Call findobjects query.findObjectsInBackgroundWithBlock { (objects:[AnyObject]?, error: NSError?) -> Void in // refresh array self.brands = [String]() // loop through array for brandObject in objects! { // get PFObjects let brandName:String? = (brandObject as! […]

将UICollectionView添加到NavigationBar

我想添加一个UICollectionView作为一个子视图到我的NavigationBar。 [self.navigationController.view addSubview:self.hotspotCollectionView]; 它似乎正常工作,但覆盖后退button,请参阅附加的屏幕截图。 有无论如何缩进collectionView,以便返回button是正确的可见? 还有一种方法来增加导航栏的高度,所以我可以在我的CollectionView中使用更大的缩略图图片? 我正在使用XCode 7和iOS9。

UICollectionView滚动很不稳定

在我的UICollectionView滚动真的是波涛汹涌。 当我滚过屏幕的一半时,它卡住了一会儿,然后继续。 如何使用SWIFT使滚动更顺畅?

UITableViewCell里的UICollectionView的自动高度

我想创build一个由标题文本,描述文本和集合视图组成的单元格。 所以我试图创build一个这样的单元格 我添加了顶部,尾部,并导致对标题和描述的超视图约束。 然后,我还添加顶部,底部,尾随和领先约束到我的UICollectionView 。 为了自动调整我的tableview单元格,我重写了viewWillAppear override func viewWillAppear(_ animated: Bool) { tableView.estimatedRowHeight = 300 tableView.rowHeight = UITableViewAutomaticDimension } 在我的自定义单元类中,我调用了layoutIfNeeded() public func setRowWithData(model: DataModel) { // set your view here contentView.layoutIfNeeded() } 我想要的是, collectionView所有单元格都显示出来了,我的tableViewCell的高度将适应它。 有没有办法做到这一点? 任何帮助,将不胜感激。 谢谢!

数据parsing后重新加载UICollection视图

我正在尝试dynamic更新一个uicollectionview。 我用这个惊人的教程如何创build一个简单的uicollection。 它使用静态数组的项目时效果很好。 我的问题 – 我想有一个uicollection填充数据从我的数据库parsing成一个新的数组。 我不知道如何重新加载parsing我的JSON数据后的uicollection。 更新的代码与答案: import UIKit class Books: UIViewController, UICollectionViewDelegate { @IBOutlet weak var bookscollection: UICollectionView! var user_id: Int = 0; //———— init —————// override func viewDidLoad() { super.viewDidLoad() } override func viewDidAppear(_ animated: Bool) { showtutorial() getuserid() } //———— show books —————// var booknames = [String]() var bookcolor = [String]() […]

'NSInvalidArgumentException':尝试滚动到无效的索引path

这是我的animationCollectionViewCustomCells的代码。 -(void)viewDidAppear:(BOOL)animated{ rowIndex = 0; [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(targetMethod) userInfo:nil repeats:YES]; } -(void)targetMethod { [self.offerCollectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:rowIndex inSection:1] atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; rowIndex=(rowIndex<parserDataContentArrayForExhibitor.count-1)?(rowIndex+1):0; // if (rowIndex == parserDataContentArrayForExhibitor.count) { // rowIndex = 0; // } } Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'attempt to scroll to invalid index path: <NSIndexPath 0xab55110> 2 indexes [1, 0]' […]

调整UICollectionViewCell以适应内容

我有一个标签被设置为调整其内容。 我想UICollectionViewCell做同样的事情。 无论如何,我无法实现这一点。 描述我目前的安排的照片可以在下面find:

无法从UICollectionViewCell实例访问Image

我正在跟随本教程对我的项目进行一些修改: http : //www.appcoda.com/ios-programming-uicollectionview-tutorial/ 我试图得到IB为我创build的UIImageView的实例。 这是我的IB的截图: 我有一个名为FeedViewCell的自定义类,它包含一个UIImageView。 这是cellForItemAtIndexPath代码: – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"Cell"; UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; UIImageView *imageView = (UIImageView *)[cell viewWithTag:100]; imageView.image = [UIImage imageNamed:[postPhotos objectAtIndex:indexPath.row]]; return cell; } 问题是,UIImageView * imageView =(UIImageView *)[单元viewWithTag:100]; 返回为零。 使用viewWIthTag方法似乎对我来说是不可思议的,但在debugging器中,我看不到imageView是UICollectionViewCell的子视图。 如果你看看这个debugging屏幕,你可以看到单元格没有任何UIImageView子视图: 但是我看到2个UIImageViews作为CollectionView的子视图。 所以这似乎是我在IB做错了事。 这并不奇怪,因为我似乎总是与IB斗争(至less看代码我可以看到发生了什么)。 感谢您的任何build议! 更新:我放弃了使用IB挂钩ImageView,并尝试在代码中创build它,如下所示: http : //cl.ly/QFxs […]

如何创build水平dynamic的UICollectionView单元格? 迅速

嘿,我试图在视图控制器中使用集合视图单元格显示一组“标签”,但我很难find一种方法,使他们能够dynamicresize取决于string的长度。 现在单个单元格的大小是固定的,所以无论何时填充单元格的string超过单元格的大小,它都会进入第二行。 我想要这样的单元格可以改变长度取决于string的长度。 所以如果是“#Vegan”这个标签,它会自动resize,这样标签就不那么大了。 同样,如果它是像“#LaptopFriendly”这样的更长的string,它将变得水平更长,以容纳string,而不是使用第二行。 垂直长度可以保持不变。 谢谢! 更新(使用Rob代码遇到错误时的界面生成器设置): 模拟器截图:

insertItemsAtIndexPaths更新错误

在UICollectionView中,我正在尝试使用performBatchUpdates:completion来更新我的网格视图。 我的数据源数组是self.results 。 这是我的代码: dispatch_sync(dispatch_get_main_queue(), ^{ [self.collectionView performBatchUpdates:^{ int resultsSize = [self.results count]; [self.results addObjectsFromArray:newData]; NSMutableArray *arrayWithIndexPaths = [NSMutableArray array]; if (resultsSize == 0) { [arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:0 inSection:0]]; } else { for (int i = 0; i < resultsSize; i++) { [arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:resultsSize + i inSection:0]]; } } for (id obj in self.results) […]