2013-02-16 72 views
4

我已经复查了一切,并希望有人可以找到我没有看到的一个愚蠢的错误。帮助簿中的锚不起作用

我正在尝试为我的应用程序构建一个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)I建目录由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我设置CFBundleHelpBookFolderAppName.help并设置CFBundleHelpBookNamecom.company.app_name.help

4)然后我抄,我内置的Xcode同时确保我所选择的选项创建文件夹参考文献目录对于任何添加的文件夹

5)然后我用帮助索引器索引目录AppName.help。确保我选择所有文件中的索引锚点信息。然后将.helpindex文件复制到它应该是的 English.lproj文件夹中。

就是这样。如果我在 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每次我做另外一个变化重新索引目录的时间来清除高速缓存。

谢谢大家!

+0

很好地概述了问题。我同意这个主题隐约涵盖。你找到解决方案吗?如何回答你自己的问题(如果你能记得6个月前)? – David 2013-09-02 00:38:54

回答

4

Sure David, 感谢您的提醒。

从我还记得什么,我的马虎文档我运行下面的命令来索引的帮助文档文件:

hiutil -vCaf ./search.helpindex English.lproj 

然而&nbsp;字符用于一两件事,我才意识到是该指数效用会抱怨任何时间。取而代之的字符&#32;

我认为这是我的情况的错误。

1

如果一切正常,并仍然无法使用帮助,请使用下面的代码。不确定您的安全问题,您可能需要研究从应用中删除文件。有时,升级时的应用程序不会更新帮助文件,并显示旧版帮助文件的缓存副本,其中不包含新的锚点。因此,下面的代码清除帮助缓存。此外,还有另一种更清洁的方法,即在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]; 


}