我的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