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