2013-02-16 39 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]; 


}