swift2上的Skyepub显示空白页

时间:2016-05-27 15:05:03

标签: ios swift skyepub

我正在使用Skyepub在swift2中的iOs上实现一个ePub阅读器。 我下载了SDK和Sample。仅使用一个ViewController创建了一个项目。

在ViewDidLoad上,我调用了makeBookViewer

    var fileName: String
    fileName = "Alice-e.epub"
    self.makeBookViewer(fileName)

从示例应用程序复制并转换为swift。

func makeBookViewer(fileName: String) {

print("BaseDirectory: \(self.getBaseDirectory())")

let rv = ReflowableViewController(startPagePositionInBook:0.0)
rv.book.isFixedLayout = false
rv.book.fontSize = 12
rv.book.fileName = fileName
rv.book.bookCode = 123456
rv.baseDirectory = self.getBaseDirectory()
rv.transitionType = 0
rv.useDOMHighlight(false)
if self.isPad() {
    rv.setVerticalGapRatio(0.17)
}
else {
    rv.setVerticalGapRatio(0.20)
}
rv.setHorizontalGapRatio(0.3)
rv.setGlobalPaging(true)
rv.showIndicatorWhileLoadingChapter(false)
rv.showIndicatorWhilePaging(false)
rv.showIndicatorWhileRotating(true)
rv.allowPageTransitionFast(true)
rv.setCustomDrawHighlight(true)

rv.dataSource = self
rv.delegate = self

let skyProvider: SkyProvider = SkyProvider()
skyProvider.dataSource = self
skyProvider.book = rv.book
rv.setContentProvider(skyProvider)
rv.setGlobalOffset(true)
rv.setDrawingHighlightOnFront(false)

self.addChildViewController(rv)
rv.view.frame = self.view.frame
rv.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
self.view!.addSubview(rv.view!)
self.view.autoresizesSubviews = true

}

ViewController显示一个空白页面,显示水印"未许可"。立即显示活动指示器。然后没有任何事情发生。

在日志上我可以看到

BaseDirectory: /Users/me/Library/Developer/CoreSimulator/Devices/6727DD2E-38BE-40E1/data/Containers/Data/Application/185322CD-BCA8-467B/Documents
2016-05-27 20:09:40.882 MyEPub[6296:175309] Application (null) Version 1 Copyrights (null)
2016-05-27 20:09:40.883 MyEPub[6296:175309] Application (null) Version 1 Copyrights (null)
2016-05-27 20:09:40.883 MyEPub[6296:175309] dealloc in Book
2016-05-27 20:09:40.884 MyEPub[6296:175309] destroy in Book
2016-05-27 20:09:40.884 MyEPub[6296:175309] processInit
2016-05-27 20:09:40.885 MyEPub[6296:175309] startServer 52326
2016-05-27 20:09:40.930 MyEPub[6296:175309] parseEncryption finished
2016-05-27 20:09:40.940 MyEPub[6296:175309] parseOpf Complete
2016-05-27 20:09:40.940 MyEPub[6296:175309] book parseXML finished

在Skyepub样本上,日志进一步进行

我已将Skyepub示例书籍文件夹中的ePub文件复制到我的BaseDirectory中。任何人都可以暗示我错过了什么。

2 个答案:

答案 0 :(得分:0)

使弱变形像:

weak var weakself = self

rv.dataSource = weakself
rv.delegate = weakself

skyProvider.dataSource = weakself

也许这可以帮到你

答案 1 :(得分:0)

我必须在objective-c中创建视图控制器,我正在使用skyepub book视图。这解决了上述问题。