我的iOS应用程序在应用商店中的尺寸相当大。我如何降低实现app thinning,以便应用程序的大小更低。在iphone应用程序中实现应用程序细化
Note
: -
- 我已经使用Images.xcassets分别把X/2倍/ 3倍的图像。
- 我也读过这个apple documentation并且负责优化级别构建设置。
- 我也使用8位PNG而不是32位PNG。
我的iOS应用程序在应用商店中的尺寸相当大。我如何降低实现app thinning,以便应用程序的大小更低。在iphone应用程序中实现应用程序细化
Note
: -
从昨天开始搜索应用程序,位代码和按需应用程序资源,现在我调试所有这些事情,并在我的示例项目的帮助下分享我从美丽apple documentation获得的知识。
应用稀疏概念涵盖bit code和按需资源。在iOS中
按需资源: - - :我将在下面详细讨论点播资源 据访问图像/视频/ .H/.M /快捷文件时需要(Yes, on-demand resouring include source code files also
)。
Resource tags
设置在您的目标中。Tag
。它将出现在“仅下载按需”下。现在到编码部分(my favourite site): -
NSBundleResourceRequest *resourceRequest;
#pragma mark - On demand resource
-(void)getOnDemandResource{
NSSet *setOfTag = [NSSet setWithObjects:@"chair", nil];
resourceRequest = [[NSBundleResourceRequest alloc]initWithTags:setOfTag];
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {
if (!resourcesAvailable) {
// resourceRequest.loadingPriority = 1;//set the downloading priority (0 - 1) , NSBundleResourceRequestLoadingPriorityUrgent
[resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:error.debugDescription preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
}else{
//// The associated resources are loaded
}
}];
}else{
// The associated resources are available
}
}];
}
结束访问按需资源在不使用时(一般当游戏等级的变化)
#pragma mark - Remove access to on demand
-(void)endAccessToOnDemandResource{
[resourceRequest endAccessingResources];
}
NOTE:-
别忘了enable On_Demand_Resources in build setting。
EXAMPLE PROJECT:- I create a sample project and uploaded here:- [http://www.dropbox.com/s/edi5zj68a4wuguh/WebOnTab.zip?dl=0][6]
请不要在这个项目中自动布局。我主要关注的是需求资源/应用程序。
总结: -因此,我们可以使用上述技术实现app thinning
on-demand resourcing
。请参阅official documentation,其中还描述了资源请求(NSBundleResourceRequest
)的tracking progress
,priorities
。
据我了解的应用程序的细化,这一切都由苹果公司完成。它着眼于目标设备是什么,所需的图像和内容将自动提供给用户。
如果你想获得更薄的应用程序,也许重构是你应该看看的主题。
没错。它由Apple负责。但是在我的问题中列出的开发人员需要注意的地方可能存在一些不足之处。你有没有关于标签的想法,这与点播资源有关? – pkc456
应用程序切片是currently not working直到另行通知。减少应用程序大小的唯一方法是减少包含在.ipa中的资源数量。
如果它们对您的应用有意义,您可以尝试使用On Demand Resources。
有谁知道如何检测点播资源下载后的位置?我正在尝试将它们用于我的游戏女巫不使用xcasset目录。我想下载纹理,然后使用它们,就好像它们是初始包的一部分,但我需要知道文件的确切位置。 – dimayak
我检查了苹果文档(https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSBundleResourceRequest_Class/index.html#//apple_ref/occ/instm/NSBundleResourceRequest/initWithTags:bundle :) ,但仍然无法找到位置。所以我在SO上提出这个问题:http://stackoverflow.com/questions/33824601/how-to-detect-where-the-on-demand-resources-are-located-after-being-downloaded – pkc456