fix epub reader playback and trial navigation
This commit is contained in:
@@ -56,6 +56,17 @@ extension RDEPUBReaderController {
|
||||
return readableContentPageCount + 1
|
||||
}
|
||||
|
||||
func isReadableTableOfContentsLocation(_ location: RDEPUBLocation) -> Bool {
|
||||
guard let policy = configuration.trialPolicy,
|
||||
let readableChapterCount = policy.readableChapterCount else {
|
||||
return true
|
||||
}
|
||||
guard let spineIndex = readerContext.normalizedSpineIndex(for: location) else {
|
||||
return true
|
||||
}
|
||||
return spineIndex < readableChapterCount
|
||||
}
|
||||
|
||||
/// 构建试读墙页承载视图(铺满一页,居中放置宿主提供的墙视图)
|
||||
func makeTrialWallPageView(reusableView: UIView?) -> UIView {
|
||||
let container = (reusableView as? RDEPUBTrialWallContainerView) ?? RDEPUBTrialWallContainerView()
|
||||
@@ -65,12 +76,19 @@ extension RDEPUBReaderController {
|
||||
}
|
||||
|
||||
/// 试读墙页容器:让宿主墙视图铺满整页
|
||||
final class RDEPUBTrialWallContainerView: UIView {
|
||||
final class RDEPUBTrialWallContainerView: UIView, RDEpubReaderCachePolicyProviding {
|
||||
|
||||
/// 宿主只提供一份试读墙 View。预加载会同时构建多个页容器,若缓存该容器会
|
||||
/// 把同一 View 从实际可见页移走,最终表现为横竖翻页的试读墙白屏。
|
||||
var shouldAvoidReaderPageCaching: Bool { true }
|
||||
|
||||
private weak var wallView: UIView?
|
||||
|
||||
func setWallView(_ view: UIView?) {
|
||||
guard wallView !== view else { return }
|
||||
// 即使 View 对象相同,只要它已被其他复用容器接管,也必须重新挂回当前页。
|
||||
if wallView === view, view?.superview === self {
|
||||
return
|
||||
}
|
||||
wallView?.removeFromSuperview()
|
||||
guard let view else { return }
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
Reference in New Issue
Block a user