注意:我使用swift 4 for osx.我想从WebView生成一个pdf文件.
目前,我的WebView加载了一个html字符串并成功显示.如果按下按钮,打印面板将打开,并准备以正确的格式打印我的WebView内容.
这是我的打印代码:
var webView = WebView()
var htmlString = "MY HTML STRING"
override func viewDidLoad() {
webView.mainFrame.loadHTMLString(htmlString, baseURL: nil)
}
func webView(_ sender: WebView!, didFinishLoadFor frame: WebFrame!) {
let printInfo = NSPrintInfo.shared
printInfo.paperSize = NSMakeSize(595.22, 841.85)
printInfo.isHorizontallyCentered = true
printInfo.isVerticallyCentered = true
printInfo.orientation = .portrait
printInfo.topMargin = 50
printInfo.rightMargin = 0
printInfo.bottomMargin = 50
printInfo.leftMargin = 0
printInfo.verticalPagination = .autoPagination
printInfo.horizontalPagination = .fitPagination
//webView.mainFrame.frameView.printOperation(with: printInfo).run()
let printOp: NSPrintOperation = NSPrintOperation(view: webView.mainFrame.frameView.documentView, printInfo: printInfo)
printOp.showsPrintPanel = true …
Run Code Online (Sandbox Code Playgroud) 当前,有一个滚动视图(整个屏幕)位于uiview(屏幕的底部)后面。我正在尝试检查uiview是否覆盖了滚动条上的标签(iphone se会发生这种情况)。有没有办法检查uiview是否覆盖了滚动视图上的标签?我尝试使用中央cgpoint在滚动视图上查看标签是否小于uiview上的一个点,但是它不允许我比较两个cgpoints的大小:
if atmLabel.center < CGPoint(x: 156, y: 570) {
buttonView.dropShadow(shadowOpacity: 0.5)
}
Run Code Online (Sandbox Code Playgroud) 在header.h中我有:
typedef struct {
int score;
int dice[6];
int scorecard[2][7];
} player;
Run Code Online (Sandbox Code Playgroud)
然后在定义.我有:
struct player do_turn(struct player user) {
for (int i = 0; i < 6; i++) {
int die = roll_die();
user.dice[i] = die;
}
return (user);
}
Run Code Online (Sandbox Code Playgroud)
在函数定义中我得到错误"函数do_turn返回不完整类型struct player"
我究竟做错了什么?