gpt4 book ai didi

iphone - 如何更改 PhoneGap 1.x 中的起始页

转载 作者:行者123 更新时间:2023-11-29 13:41:12 25 4
gpt4 key购买 nike

我试图通过下载更新包并覆盖 PhoneGap 项目的 www 文件来更新 PhoneGap 项目的 Web 文件。问题是 www 文件似乎存储在包中,而不是文档目录中。我可以在启动时将这些文件复制到文档目录,但我仍然不知道如何告诉 PhoneGap 使用文档目录中的 index.html 文件而不是原始 www 目录。

最佳答案

我能够通过覆盖 +(NSString*)wwwFolderName+ (NSString*) pathForResource:(NSString*)resourcepath 来解决这个问题我相信通过覆盖 + (NSString*) pathForResource:(NSString*)resourcepath 我可能会在 PhoneGap 的其他部分遇到一些问题。

+(NSString*)wwwFolderName {
return [NSString stringWithFormat:@"%@/www",[super applicationDocumentsDirectory]];
}
+ (NSString*) pathForResource:(NSString*)resourcepath
{
NSBundle * mainBundle = [NSBundle mainBundle];
NSMutableArray *directoryParts = [NSMutableArray arrayWithArray:[resourcepath componentsSeparatedByString:@"/"]];
NSString *filename = [directoryParts lastObject];
[directoryParts removeLastObject];

NSString* directoryPartsJoined =[directoryParts componentsJoinedByString:@"/"];
NSString* directoryStr = [self wwwFolderName];

if ([directoryPartsJoined length] > 0) {
directoryStr = [NSString stringWithFormat:@"%@/%@", [self wwwFolderName], [directoryParts componentsJoinedByString:@"/"]];
}
if (![[self wwwFolderName] isEqualToString:@"www"]) {
return [NSString stringWithFormat:@"%@/%@",[self wwwFolderName],[self startPage]];
}

return [mainBundle pathForResource:filename
ofType:@""
inDirectory:directoryStr];
}

关于iphone - 如何更改 PhoneGap 1.x 中的起始页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9086145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com