我在VC中制定了一个协议,其中从我的swift文件类中获取了位置地标。在我的快速课堂上,我已经声明了这样的协议,
weak var delegate: HandleMapSearch?
Run Code Online (Sandbox Code Playgroud)
但是xcode向我显示错误'weak' must not be applied to non-class-bound 'HandleMapSearch'; consider adding a protocol conformance that has a class bound。之前运行良好,但现在运行应用程序时显示此错误。这是做什么用的,我该如何删除该错误?这就是我在VC类中创建协议的方式。
protocol HandleMapSearch {
func dropPinZoomIn(placemark:MKPlacemark)
}
Run Code Online (Sandbox Code Playgroud) 我有一个表格视图,其中有两个部分。两个部分下面都包含 3 个单元格。现在,当我选择任何单元格时,它会显示勾号,但它会从两个部分中选择一个单元格。我尝试了一些代码,但它不起作用。我希望用户可以从两个部分中选择一个单元格,并且当表视图加载时,应预先选择其第一个单元格。我怎样才能做到这一点?我对单元格的预选有点困惑。我的单元格选择代码是这样的,
self.filterTableView.allowsSelection = true
extension FiltersVC: UITableViewDelegate,UITableViewDataSource{
func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return sectionTitles[section]
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menuItems[section].count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 60
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = filterTableView.dequeueReusableCell(withIdentifier: "filterCell", for: indexPath) as! FiltersTableViewCell
cell.tilteLbl.text = menuItems[indexPath.section][indexPath.row] …Run Code Online (Sandbox Code Playgroud) 我有使用 ARSCNView 的应用程序。我正在尝试通过单击按钮截取屏幕截图并将该图像保存在图库中。但是当我截取屏幕截图时,它不会在该屏幕上显示内容。只需显示该图像,我上面有一些标签,但它没有在图像中显示。这是我的代码
@IBAction func captureImage(_ sender: Any) {
image = sceneView.snapshot()
UIImageWriteToSavedPhotosAlbum(image!, nil, nil, nil)
}
Run Code Online (Sandbox Code Playgroud)
如何在屏幕截图中显示 ARSCView 上的标签和按钮?