1
我是RxSwift的新手,试图围绕它来包裹我的头。我在按下UIAlertController时在单元格中显示UIButton时遇到了问题。在RxSwift的UICollectionViewCell中订阅UIButton tap?
private func setupCellConfiguration() {
bookListViewModel.data
.bindTo(collectionView.rx.items(cellIdentifier: BookListCell.Identifier, cellType: BookListCell.self)) { [unowned self] (row, element, cell) in
cell.configureForBook(book: element)
cell.moreButton.rx.tap.subscribe { [weak self] in
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) {(action) in
self?.dismiss(animated: true, completion: nil)
}
alertController.addAction(cancelAction)
let destroyAction = UIAlertAction(title: "Delete", style: .destructive) { (action) in
}
alertController.addAction(destroyAction)
self?.present(alertController, animated: true)
}
.addDisposableTo(self.disposeBag)
}
.addDisposableTo(disposeBag)
}
按下时没有任何反应。我在这里做错了什么?
你使用Xcode的调试器仔细检查,如果自己不为零,如果警报控制器被实例化成功?通过这种方式,您可以尝试隔离问题所在(是Rx问题,还是引用问题)。 – iwillnot