我在同一个视图控制器上使用 UITableView 和 UICollectionView 。
我想更改 UICollectionView 的滚动方式,因此我在扩展中添加了一个scrollViewWillBeginDragging和 一个函数。scrollViewWillEndDragging
然而,scrollViewWillBeginDragging ascrollViewWillEndDragging也是尽管不在同一个扩展中,但
我该如何解决?有没有办法只选择 UICollectionView?
这是我的代码的简短版本:
extension ViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
// This is where I put all of the UICollectionView code, including `scrollViewWillBeginDragging` and a `scrollViewWillEndDragging`
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
// Why is the code in here affecting the UITableView?
}
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
// Same as with `scrollViewWillBeginDragging`
}
}
extension ViewController: UITableViewDelegate, …Run Code Online (Sandbox Code Playgroud) 我正在将一个道具传递给一个新组件并尝试使用它来执行 graphql 查询。它看起来像这样。
import React from "react"
import { graphql, useStaticQuery } from "gatsby"
import Img from "gatsby-image"
const ComponentName = props => {
const getImage = graphql`
{
image: file(relativePath: { eq: ${props.img} }) {
childImageSharp {
fluid {
...GatsbyImageSharpFluid
}
}
}
}
`
const data = useStaticQuery(getImage)
return (
<li>
<Img
fluid={data.image.childImageSharp.fluid}
/>
</li>
)
}
export default ComponentName
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误 BabelPluginRemoveGraphQLQueries: String interpolations are not allowed in graphql fragments. Included fragments should be referenced as...MyModule_foo.
我尝试了各种不同的技巧来摆脱“字符串插值”错误。但是它们都不起作用(它只是每次都显示不同的错误)。
我假设您不能使用 …
在 Swift 中,要从 Firestore 检索数组,我使用:
currentDocument.getDocument { (document, error) in
if let document = document, document.exists {
let people = document.data()!["people"]
print(people!)
} else {
print("Document does not exist")
}
}
Run Code Online (Sandbox Code Playgroud)
我收到看起来像这样的数据
(
{
name = "Bob";
age = 24;
}
)
Run Code Online (Sandbox Code Playgroud)
但是,如果我要单独检索名称,通常我会这样做print(document.data()!["people"][0]["name"])。
但我得到的回应是 Value of type 'Any' has no subscripts
如何访问people数组内该对象内的名称键?