【问题标题】:Anchors in help-book not working帮助手册中的锚点不起作用
【发布时间】: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


【解决方案1】:

当然,大卫, 谢谢提醒。

根据我的回忆和我草率的文档,我运行以下命令来索引帮助文档文件:

hiutil -vCaf ./search.helpindex English.lproj

但是我意识到的一件事是索引实用程序会在任何时候使用 &amp;nbsp; 字符时抱怨。而是替换字符&amp;#32;

我认为这是我的问题。

【讨论】:

    【解决方案2】:

    如果一切正常,并且如果帮助不起作用,请使用下面的代码。不确定您的安全问题,您可能需要研究从应用程序中删除文件。有时升级时的应用程序不会更新帮助文件并显示旧帮助文件的缓存副本,其中不包含新的锚点。因此下面的代码清除了帮助缓存。还有另一种更简洁的方法,您可以在 Info.plist 中增加帮助文件的构建版本,该文件位于帮助包中,而不是应用程序信息 plist。这些字段是 CFBundleShortVersionString CFBundleVersion

    -(void)clearCacheHelp {
    NSArray *arguments1 = [NSArray arrayWithObjects:@"helpd",nil];
    
    NSTask * list1 = [[NSTask alloc] init];
    [list1 setLaunchPath:@"/usr/bin/killall"];
    [list1 setArguments:arguments1];
    
    
    NSPipe * out1 = [NSPipe pipe];
    [list1 setStandardOutput:out1];
    
    [list1 launch];
    [list1 waitUntilExit];
    
    
    NSString *home = [self homeDirectory];
    
    home = [home stringByAppendingPathComponent:@"Library/Caches/com.apple.helpd"];
    
    NSArray *arguments  = [NSArray arrayWithObjects:@"-rf",home,nil];
    
    
    NSTask * list = [[NSTask alloc] init];
    [list setLaunchPath:@"/bin/rm"];
    [list setArguments:arguments];
    
    
    NSPipe * out = [NSPipe pipe];
    [list setStandardOutput:out];
    
    [list launch];
    [list waitUntilExit];
    
    
    
    NSString *home2 = [self homeDirectory];
    
    home2 = [home2 stringByAppendingPathComponent:@"Library/Caches/com.apple.helpviewer"];
    
    NSArray *arguments2  = [NSArray arrayWithObjects:@"-rf",home2,nil];
    
    
    NSTask * list2 = [[NSTask alloc] init];
    [list2 setLaunchPath:@"/bin/rm"];
    [list2 setArguments:arguments2];
    
    
    NSPipe * out2 = [NSPipe pipe];
    [list2 setStandardOutput:out2];
    
    [list2 launch];
    [list2 waitUntilExit];
    
    
    NSArray *arguments3  = [NSArray arrayWithObjects:@"-rf",@"~/Library/Caches/com.apple.helpd",nil];
    
    
    NSTask * list3 = [[NSTask alloc] init];
    [list3 setLaunchPath:@"/bin/rm"];
    [list3 setArguments:arguments3];
    
    
    NSPipe * out3 = [NSPipe pipe];
    [list3 setStandardOutput:out3];
    
    [list3 launch];
    [list3 waitUntilExit];
    
    
    NSArray *arguments4  = [NSArray arrayWithObjects:@"-rf",@"~/Library/Caches/com.apple.helpviewer",nil];
    
    
    NSTask * list4 = [[NSTask alloc] init];
    [list4 setLaunchPath:@"/bin/rm"];
    [list4 setArguments:arguments4];
    
    
    NSPipe * out4 = [NSPipe pipe];
    [list4 setStandardOutput:out4];
    
    [list4 launch];
    [list4 waitUntilExit];
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 1970-01-01
      • 2011-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多