- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在努力实现 Pinterest我的应用中的布局
我使用以下委托(delegate)方法来实现并动态设置单元格高度
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let boundingRect = CGRect(x: 0, y: 0, width: self.view.frame.size.width / 2 - 20, height: CGFloat(MAXFLOAT))
let data = articles[indexPath.row]
let rect = AVMakeRect(aspectRatio: (data.coverImage?.size)!, insideRect: boundingRect)
return CGSize(width: rect.width, height: rect.height + 120) // Added 120 for a description I will add later
}
但我得到了以下结果:
灰色背景是单元格的背景,可以看到每个单元格都有自己的高度(符合预期)但有多余的空格,我不知道如何删除。
我该如何解决这个问题?
最佳答案
你可以查看 raywenderlich 教程:
https://www.raywenderlich.com/164608/uicollectionview-custom-layout-tutorial-pinterest-2
如果您想在到达最后一个单元格时加载新数据,则必须编辑一些代码。
在 PinterestLayout.swift 中,做以下更改:
guard cache.isEmpty == true, let collectionView = collectionView else {
return
}
到
guard let collectionView = collectionView else {
return
}
//这个文件名可能和你的不一样
在 PhotoStreamViewController.swift 中,添加如下代码:
override func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
if (indexPath.row == photos.count - 1 ) {
//it's your last cell
// Add more data to the array according your requirement
// After adding data reload collection view
collectionView.reloadData()
}
}
关于swift - UICollectionView 动态单元格高度(Pinterest 布局),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41693190/
就像添加一类“data-pin-pin”而不是“data-pin-nopin”? slider 中有图像,但它们都是背景图像,因此当前 pin 按钮不起作用。 谢谢! 最佳答案 Pinterest 无
通常,要获取 Pinterest 版 block 的 RSS 提要,只需将“.rss”添加到 URL 末尾即可。 例如,对于 http://www.pinterest.com/philchairez/
我正在搜索 Pinterest 的提要移动应用程序 API。 我可以知道如何从 Pinterest 获取搜索提要吗? API。 最佳答案 这里有文档 https://developers.pinter
Pinterest Widget Builder允许灵活地创建小部件以放置在您的网站上。我在 this page 上加了一个,但您可以为小部件设置的宽度似乎有限制。例如,我将宽度设置为 1170,但它
自今年年初(整整 7 个月!)以来,关于 Pinterest API 中的搜索功能出现了几个问题。 示例:我在这里得到与我们的 friend leonardo 相同的回复:Pinterest API
我们希望将网站设置为 oEmbed 提供商。 官方文档 ( http://oembed.com/ ) 说: Configuration for oEmbed is very simple. Provi
有没有办法在 React Native 中使用 flexbox 来实现 Masonry/Pinterest 风格的列? 最佳答案 在 React Native 中,远程图像不会在加载时调整大小(参见“
我想知道是否有相应的方法可以打开 pinterest 链接,如果安装了 pinterest 应用程序,或者如果它不在 Facebook 等设备中,则使用浏览器。对于 Facebook,我使用以下代码
对于 iOS 8,Pinterest 有一个共享扩展。如何设置图片来源网址和描述属性?我正在使用 UIActivityViewController。我是否使用 UIImage、NSURL 用于 sou
目前,我正在尝试重新创建类似 Instagram/Pinterest iOS 个人资料页面的内容,您可以在具有不同数据和布局的部分之间滑动,同时标题不会水平滚动,而是与每个部分垂直滚动。与当前 Ins
在页面 https://developers.pinterest.com/tools/access_token/您可以生成访问 token 。有谁知道那个 token 的生命周期是多少?它会在固定时间
我们的 prod pinterest 应用程序有问题。 获得 token 后: "{"access_token": "AabcYgRUKiaBI45HYM72teXO6fZaFQoEhVxkxaREo
我正在寻找一种从给定用户名获取板名称列表的方法。我知道 pinterest 已经为给定用户的所有 pin 和给定 pinboard 的所有 pin 提供了 rss。 来自给定用户的所有 Pin 图:p
这个文档很清楚:http://developers.pinterest.com/api_docs/oauth_code_exchange/ 我需要 code用访问 token 交换它。但是访问此代码的
任何人都可以对(未受过教育的)猜测如何使用未发布的Pinterest API进行分页吗? 例如,此链接:https://api.pinterest.com/v3/pidgets/boards/grai
我正在通过使用此url访问Pinterest API以获取用户信息,但是我找不到如何为Pinterest生成访问 token 的方法。 根据这个blog post,它说 Pinterest uses
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。
尝试实现“固定它”按钮,但它会为每张图片返回以下问题。我们在整个网站上使用 SSL,我想知道这是否相关。 有什么想法吗? {"route_pattern": "^/resource/:name/:me
我集成了“Pin It”按钮以在 pinterest.com 上分享我的产品图片。但它不会在我网站上的 pin it 按钮前显示 pin 计数。我写了下面的代码。 这是我网站上的固定按钮 &这个
我有一个 AngularJS 应用程序,它是一个单页应用程序。在每个单独的页面上都会加载 Pinterest 板,这是通过 Pinterest 的小部件构建器完成的: This can be foun
我是一名优秀的程序员,十分优秀!