Swift 源文件中的编辑器占位符
Swift Editor Placeholder in source file
你好 swift 错误 "Swift Editor Placeholder In Source File"
这是我的代码
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: <#T##IndexPath#>) as! CustomBrandCell
let brandImage: UIImage = UIImage(named: self.brands[indexPath.row].name)!
cell.brandImageView.image = brandImage
return cell
}
试试这个。希望能解决你的问题
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
// get a reference to your storyboard cell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath as IndexPath) as! CustomBrandCell
let brandImage: UIImage = UIImage(named: self.brands[indexPath.row].name)!
cell.brandImageView.image = brandImage
return cell
}
我在SO上多次发现同样的问题。但其中 none 给出了我正在寻找的答案。
当您的代码中有其中之一(其中显示 "String" 且背景为蓝色)时,您会得到 Placeholder in source file
。
占位符是给我们程序员用的。它说 "here should be a value of the type String"。您可以单击它并开始键入,以简单地用例如变量名替换它。您也可以按 Tab 键自动 select 下一个占位符。这在调用具有多个参数(因此具有多个占位符)的函数时非常有用。
占位符实际上只是普通文本 (<#T##Strign#>),但 XCode "translates" 它看起来像它的样子。
在你的例子中,错误在第三行。
...withReuseIdentifier: "Cell", for: <#T##IndexPath#>) as! CustomBrandCell
如您所见,<#T##IndexPath#>
是我之前提到的普通文本的占位符。您可能希望它是 indexPath
尝试使用 cmd + shift + k 清理项目并再次 运行 您的代码。这解决了我的问题。
你好 swift 错误 "Swift Editor Placeholder In Source File" 这是我的代码
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: <#T##IndexPath#>) as! CustomBrandCell
let brandImage: UIImage = UIImage(named: self.brands[indexPath.row].name)!
cell.brandImageView.image = brandImage
return cell
}
试试这个。希望能解决你的问题
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
// get a reference to your storyboard cell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath as IndexPath) as! CustomBrandCell
let brandImage: UIImage = UIImage(named: self.brands[indexPath.row].name)!
cell.brandImageView.image = brandImage
return cell
}
我在SO上多次发现同样的问题。但其中 none 给出了我正在寻找的答案。
当您的代码中有其中之一(其中显示 "String" 且背景为蓝色)时,您会得到 Placeholder in source file
。
占位符是给我们程序员用的。它说 "here should be a value of the type String"。您可以单击它并开始键入,以简单地用例如变量名替换它。您也可以按 Tab 键自动 select 下一个占位符。这在调用具有多个参数(因此具有多个占位符)的函数时非常有用。
占位符实际上只是普通文本 (<#T##Strign#>),但 XCode "translates" 它看起来像它的样子。
在你的例子中,错误在第三行。
...withReuseIdentifier: "Cell", for: <#T##IndexPath#>) as! CustomBrandCell
如您所见,<#T##IndexPath#>
是我之前提到的普通文本的占位符。您可能希望它是 indexPath
尝试使用 cmd + shift + k 清理项目并再次 运行 您的代码。这解决了我的问题。