【发布时间】:2013-02-01 13:31:27
【问题描述】:
我已经仔细检查了所有内容,希望有人能找到我没有看到的愚蠢错误。
我正在尝试为我的应用程序构建 Apple 帮助部分,它正确地进入了登录页面,但是没有一个锚点起作用。登录页面名为index.html,另一个页面名为test.html,位于pgs 目录中。
在 index.html 中我有:
<a href="help:anchor=support bookID=com.company.app_name.help">Link to another page</a>
在 test.html 我有:
<a name="support"></a>
所以这是我为了达到现在的位置而遵循的步骤:
1) 我建立了Apple documentation指定的目录
AppName.help/
Contents/
Info.plist
Resources/
shrd/
English.lproj/
index.html
search.helpindex
pgs/
test.html
2) 我按照 Apple 文档中的说明构建了 Help Info.plist。包含在 Info.plist 中,我将 CFBundleIdentifier 设置为 com.company.app_name.help。
3) 在我的应用 Info.plist 中,我将 CFBundleHelpBookFolder 设置为 AppName.help 并将 CFBundleHelpBookName 设置为 com.company.app_name.help
4) 然后我复制了我在 Xcode 中构建的目录,同时确保选择了选项为任何添加的文件夹创建文件夹引用。
5) 然后我使用Help Indexer 来索引目录AppName.help。确保我选择了在所有文件中为锚信息编制索引的选项。然后我将 .helpindex 文件复制到它应该在的 English.lproj 文件夹中。 p>
就是这样。如果我将以下链接放在 index.html 文件中,我注意到我的应用程序可以正常工作。
<a href="pgs/test.html">Click this link</a>
这也是我的 index.html 代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AppName Help</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex" />
<meta name="AppleTitle" content="AppName Help" />
<meta name="AppleIcon" content="../shrd/icon.png" />
</head>
<body>
<a href="help:anchor=support bookID=com.company.app_name.help">Link to another page</a>
</body>
这是 test.html 的代码。
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing Links</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="anchors" />
</head>
<body>
<a name="support"></a>Does linking work?<br/>
</body>
</html>
这是我的帮助文件的 Info.plist。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en_us</string>
<key>CFBundleIdentifier</key>
<string>com.company.app_name.help</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>AppName</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>2</string>
<key>CFBundleSignature</key>
<string>hbwr</string>
<key>CFBundleVersion</key>
<string>2</string>
<key>CFBundleHelpBookName</key>
<string>AppName Help</string>
<key>HPDBookAccessPath</key>
<string>index.html</string>
<key>HPDBookIconPath</key>
<string>shrd/icon.png</string>
<key>HPDBookIndexPath</key>
<string>search.helpindex</string>
<key>HPDBookKBProduct</key>
<string>app_name1</string>
<key>HPDBookKBURL</key>
<string>http://www.company.com</string>
<key>HPDBookRemoteURL</key>
<string>http://www.company.com</string>
<key>HPDBookTitle</key>
<string>AppName Help</string>
<key>HPDBookType</key>
<string>3</string>
</dict>
</plist>
我还关注了这篇文章:http://www.cocoabuilder.com/archive/cocoa/312037-updating-an-app-help.html,以在每次更改时清除缓存,并重新索引目录。
谢谢大家!
【问题讨论】:
-
很好地概括了问题。我同意这个话题被模糊地涵盖了。你找到解决办法了吗?回答你自己的问题怎么样(如果你记得 6 个月前的话)?
-
调用锚点很快 4: NSHelpManager.shared.openHelpAnchor(NSHelpManager.AnchorName(rawValue:"MyAnchor"), inBook: NSHelpManager.BookName(rawValue: "com.company.App.help" ) )
标签: cocoa xcode4 help-viewer apple-help