如何只为一个模型设置索引?

问题描述

我想使用 QLPreviewController 预览列表中的某些项目。预览控制器获取我的对象的列表:

func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
        return objects.value.count
    }
    
    func previewController(_ controller: QLPreviewController,previewItemAt index: Int) -> QLPreviewItem {
        // returns path
    }

要在两个模型之间有所不同并仍在表视图中获取索引路径,我必须压缩可观察对象:

_ = Observable.zip(tableView.rx.itemSelected,tableView.rx.modelSelected(Structured.self)).subscribe(onNext: { [weak self] indexPath,model in
            guard let self = self else { return }
            if model is File {
                    self.quickLookController.currentPreviewItemIndex = indexPath.row
                    self.parent?.navigationController?.show(self.quickLookController,sender: self)
            }
            if model is FileStructure {
                let structure = model as! Structure
                let sb = UIStoryboard(name: "Main",bundle: nil)
                let fileListViewCtrl = sb.instantiateViewController(withIdentifier: "FileListViewController") as! FileListViewController
                self.navigationController?.pushViewController(fileListViewCtrl,animated: true)
            }
        })

每次我在列表中选择一个文件时,都会在预览本身中得到没有要预览的项目

我认为主要的问题是我给了 QLPreviewController 对象列表,但是随后将索引传递给对象和文件结构,它们根本不一样。

关于如何获取我的文件模型的索引路径的任何建议?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)