어떤 시나리오에서는 앱의 아이콘 이름과 시작 이미지의 이름을 가져와야 할 수도 있습니다. 예를 들어, 앱이 전경에있을 때 원격 알림을받지 만 알림 표시 줄에는 알림 알림이 없습니다. 현재 시뮬레이션 된 알림 프롬프트를 만들고 싶습니다. 아이콘 이름을 사용해야합니다. 예를 들어, 특정 컨트롤러를로드 할 때 컨트롤러의 배경 이미지를 시작 이미지로 설정하고 시작 이미지 이름을 사용해야합니다.
실제로 아이콘 이미지는 시스템 Appicon 폴더에 배치되며 시작 이미지는 시스템 LaunchImage 폴더에 배치됩니다. 이 이미지의 이름은 다른 일반 리소스 이미지의 이름과 다릅니다.
예를 들어 단순하고 거칠어 봅시다.
현재 프로젝트가 iPhone 장치 만 지원하고 수직 화면 만 지원한다고 가정합니다. 그리고 Appicon 아이콘과 시작 이미지는 현재 프로젝트에서 설정되었습니다.
아이콘 아이콘 이름과 시작 이미지 이름을 얻는 방법은 무엇입니까?
코드에서 로그를 인쇄합니다.
/** 앱의 아이콘 아이콘 이름 가져 오기*/- (void) getAppiconname {nsdictionary*infodict = [[nsbundle mainbundle] infodictionary]; // 앱에서 모든 아이콘 이름 가져 오기 nsarray*iconsarr = infodict [@"cfbundleicons"] [@"@"@"cfbundleprimaryicon"] [@"cfbundleiconfiles"]; // 마지막 아이콘 이름 nsstring *iconlastname = [iconsarr lastobject]; // 아이콘 이름 nslog (@"iconsarr : %@"; "iconsarr); %@", iconlaunchName);/*인쇄 로그 : ICONSARR : (Appicon29X29, AppICon40X40, AppIcon60x60) iconlastName : Appicon60x60*/}/** 앱의 스타트 업 이미지의 이름을 얻고이 컨트롤러의 배경 이미지로 설정하십시오. *런치 이마 메나 이름 = @""; // 이미지 이름 변수 cgfloat screenheight = [uiscreen mainscreen] .bounds.size.height; // 현재 장치와 일치하는 시작 이미지 이름을 얻습니다. iPodlaunchImagename = @"unkerimage-700-568h";} else if (screenHeight == 667) {// 6, 6SlaunchImagename = @"unlainImage-800-667H";} else (screenHeight == 736) {// 6PLUS, 6SPLUINGENAME = @"launchImage-800-landscape-736h";} if (unkerimagename.length <1) return; // 장치 시작 이미지는 컨트롤러 uiimage *img = [uiimage imageNamed : launchImagename]의 배경 이미지입니다. self.view.backgroundcolor = [uicolor colorwithpatternimage : img]; }현재 iPhone 장치 만 지원하고 수직 화면 장면 만 지원하는 모든 시작 이미지 정보를 인쇄합니다.
/** 앱에서 모든 시작 이미지 이름 정보를 인쇄*/- (void) printalllaunchimageinfo {nsdictionary*infodict = [[nsbundle mainbundle] infodictionary]; // 모든 시작 이미지 정보를 가져옵니다. 이미지 정보 배열 NSARRAY *LANKEIMAGESARR = infodict [@"uilaunchImages"]; nslog (@"unkerimagesarr : %@", 런치 이미지 아르); /* 인쇄 로그 : 시작 이미지의 이름은 고정 된 LaunchImagesArr입니다. UILACHIMAGEMINOSTION = "8.0"; "uilaunchimageize는"{375, 667} "; 480} ";}, {uilaunchimageminumsversion ="7.0 "; uilaunchimagename ="launchImage-700-568h "; uilaunchImageorientation = portrait; uilaunchimagesize ="{320, 568} ";} */} 프로젝트 Appicon 아이콘 및 시작 이미지 정보는 [[NSBundle MainBundle] InfoDictionary]에서 얻을 수 있음을 알았습니다. 또한 버전, 앱 이름, 장치 유형 및 지원 방향과 같은 앱에 대한 다른 정보도 포함되어 있습니다. . .
확인하려면 모든 정보를 인쇄하십시오.
/** 인쇄 앱 프로젝트 구성 정보*/- (void) printInfodictionary {nsdictionary*infodict = [[nsbundle mainbundle] infodictionary]; nslog (@"%@", infodict); /* 인쇄 로그 : {buildMachineOSBuild = 15G31; cfbundledevelopmentregion = en; cfbundleExecutable = tantest; cfbundleicons = {cfbundleprimaryicon = {cfbundleiconfiles = (appicon29x29, appicon40x40, appicon60x60); }; }; cfbundleIdentifier = "net.tan.xxx"; cfbundleinfodictionaryversion = "6.0"; cfbundleinfoplisturl = "info.plist- 파일 : ///users/px/library/developer/coresimulator/devices/7020368b-c160-42c0-b3c5-5f958fa82ef5/data/containers/bundle/application/77d8c333-a6af-4183-b79a-a5bedcd08e1a/1a/1a/1a/1a1a/1a1a/1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a cfbundlename = tantest; cfbundlenumericversion = 16809984; cfbundlepackagetype = appl; cfbundleshortversionstring = "1.0"; cfbundlesignature = "????"; cfbundlesupportedplatforms = (iphoneimulator); cfbundleversion = 1; dtcompiler = "com.apple.compilers.llvm.clang.1_0"; dtplatformBuild = ""; dtplatformname = iPhoneImulator; dtplatformversion = "9.3"; DTSDKBUILD = 13E230; dtsdkname = "iPhonesImulator9.3"; dtxcode = 0731; dtxcodebuild = 7d1014; lsrequiresiphoneos = 1; 최소 소송 = "6.0"; uidevicefamily = (); uilaunchImageFile = unkerImage; uilaunchImages = ({uilaunchimageminumsversion = "8.0"; uilaunchimagename = "unlainmage-800-portrait-736h"; uilaunchimageorientation = portrait; uilaunchImagesize = "{414, 736}"; Uilaunchimagename = "uilaunchimageorientation ="{414, 736} "; Portrait; UILaunchImageSize = "{375, 667}"; }, { UILaunchImageMinimumOSVersion = "7.0"; UILaunchImageName = "LaunchImage-700"; UILaunchImageOrientation = Portrait; UILaunchImageSize = "{320, 480}"; }, { UILaunchImageMinimumOSVersion = "7.0; uilaunchStoryboardName = 런치 스크린; uimainstoryboardfile = main; uirequiredDeviceCapabilities = (ARMV7); UISUpportedInterfaceorientations = (uiinterfaceorientationportrait); } */} -------- 다음으로, Appicon 및 LaunchImage가 어떻게되는지, 앱이 iPhone 및 iPad 장치와 수평 및 수직 스크린을 모두 지원할 때 얻는 방법을 살펴 보겠습니다.
먼저 두 그림을 추가 한 다음 테스트 코드를 추가하십시오.
테스트 코드 :
1. Appicon의 모든 아이콘 아이콘 이름을 얻으십시오
/** iPhone 및 iPad를 지원하고, 앱의 아이콘 아이콘 이름을 가져옵니다 */- (void) getAppiconname {nsdictionary *infodict = [[nsbundle mainbundle] infodictionary]; // 앱에서 모든 아이콘 이름을 가져옵니다. nsArray *iconsarr = infodict [@"cfbundleicons"] [@"cfbundleprimaryicon"] [@"cfbundleiconfiles"]; // 마지막 아이콘 이름 NSString *iconLastName = [iconsarr lastObject]; // 아이콘 이름 NSLOG (@"iconsarr : %@", iconsarr); nslog (@"iconlastname : %@", iconlastname); / * 인쇄 로그 (29pt 및 40pt iPhone 및 iPad가 사용됩니다; 60pt --- iPhone, 76pt 및 83.5pt --- iPad) : iConsarr : (Appicon29x29, Appicon40x40, Appicon60x60, Appicon76x76, "Appicon83.5x83.5") iconlastname : Appicon83.5x83.5 */}. 2. iPhone 및 iPad 개발을 지원할 때 시작 사진을 찍고 수평 및 수직 스크린을 지원하고 배경 사진 코드로 설정하십시오.
(iPhone 장치에는 플러스에 두 개의 그림 세트 만 있습니다.
/** iPhone 및 iPad를 지원하고, 수평 및 수직 화면을 지원하고, 앱의 시작 이미지의 이름을 가져 와서이 컨트롤러의 배경 이미지로 설정하십시오*/- (void) getLaunchimagename {nsstring*launchimagename = @""; // 이미지 이름 변수 cgfloat screenheight = [uiscreen mainscreen] .bounds.size.height; // 스크린 높이 CGFLOAT ScreenWidth = [UISCREEN MainScreen] .Bounds.Size.Width; // 화면 너비 // 장치 인터페이스 방향 uiinterfaceorientation 방향 = [UIAPPLICATION SHAREDAPPLICATION] .STATUSBARORINTATION; bool isportrait = uiinterfaceorientationisportrait (Orientation); // 수직 스크린 Islandscape = uiinterfaceorientationislandscape (오리엔테이션); // 수평 스크린이있는 곳 // 현재 장치 // 4, 4S 수직 스크린, 수평 스크린과 일치하는 시작 이미지 이름을 얻을 수있는 곳. (IslandScape && screenwidth == 480)) {unkerImagename = @"unkerImage-700"; } // 5, 5c, 5s, iPod 수직 화면, 수평 화면 else if ((isportrait && screenheight == 568) || (IslandScape && screenwidth == 568)) {unkerImagEname = @"unkerImage-700-568H"; } // 6, 6S 세로 화면, 수평 화면 else if ((isportrait && screenheight == 667) || (IslandScape && screenwidth == 667)) {unkerImagename = @"launchImage-800-667H"; } // 6plus, 6splus 수직 화면 else if (isportrait && ScreenHeight == 736) {unkerImagename = @"unkerImage-800-portrait-736h"; } // 6Plus, 6SPlus 수평 화면 else if (IslandScape && screenwidth == 736) {unkerImagename = @"launchImage-800-landscape-736h"; } // iPad 수직 화면 else if (isportrait && screenheight == 1024) {unkerImagename = @"unkerImage-700-portrait"; } // iPad 수평 화면 else if (IslandScape && screenwidth == 1024) {unkerImagename = @"unkerImage-700-landscape"; } if (launchImagename.length <1) 리턴; // 장치 시작 이미지는 컨트롤러 UIIMAGE *IMG = [uiimage imageNamed : 런치 이마 메남]의 배경 이미지입니다. self.view.backgroundcolor = [uicolor colorwithpatternimage : img];}3. 모든 시작 이미지 정보를 인쇄하십시오
/** 앱에서 모든 시작 이미지 이름 정보를 인쇄*/- (void) printalllaunchimageinfo {nsdictionary*infodict = [[nsbundle mainbundle] infodictionary]; // 모든 시작 이미지 정보를 가져옵니다. 이미지 정보 배열 NSARRAY *LANKEIMAGESARR = infodict [@"uilaunchImages"]; nslog (@"unkerimagesarr : %@", 런치 이미지 아르); /* 인쇄 로그 : 시작 이미지의 이름은 고정 된 LaunchImagesArr입니다. UILACHIMAGEMINOSTION = "8.0"; "uilaunchimageize는"{375, 667} "; 480} ";}, {uilaunchimageminuminiMISVERSION ="7.0 "; uilaunchImagename ="launchImage-700-568H "; uilaunchImageorientation = portrait; uilaunchImagesize ="{320, 568}; = "LaunchImage-700-portrait"; uilaunchimagesize = "{768, 1024}"; }, {uilaunchImageminumSversion = "7.0"; UILAUNCHIMAGENAME = "LANKEIMAGE-700-LANDSCAPE"; uilaunchimageorientation = 풍경; uilaunchimagesize = "{768, 1024}"; }) */} 4. 모든 구성 정보를 인쇄하십시오
/** 인쇄 앱 프로젝트 구성 정보*/- (void) printInfodictionary {nsdictionary*infodict = [[nsbundle mainbundle] infodictionary]; nslog (@"%@", infodict); /* 인쇄 로그 : {buildMachineOSBuild = 15G31; cfbundledevelopmentregion = en; cfbundleExecutable = tantest; cfbundleicons = {cfbundleprimaryicon = {cfbundleiconfiles = (appicon29x29, appicon40x40, appicon60x60, appicon76x76, "appicon83.5x83.5"); }; }; cfbundleIdentifier = "net.tan.xxx"; cfbundleinfodictionaryversion = "6.0"; cfbundleinfoplisturl = "info.plist- 파일 : /// 사용자/px/library/developer/coresimulator/devices/3246F9AE-1D73-4E4F-8DDF-F591DBE64 F63/데이터/컨테이너/번들/애플리케이션/7DD6C793-F882-43CF-9897-1433411289E6/TANTEST.APP/"; cfbundlename = tantest; cfbundlenumericversion = 16809984; cfbundlepackagetype = appl; cfbundleshortversionstring = "1.0"; cfbundlesignature = "????"; cfbundlesupportedplatforms = (iphoneimulator); cfbundleversion = 1; dtcompiler = "com.apple.compilers.llvm.clang.1_0"; dtplatformBuild = ""; dtplatformname = iPhoneImulator; dtplatformversion = "9.3"; DTSDKBUILD = 13E230; dtsdkname = "iPhonesImulator9.3"; dtxcode = 0731; dtxcodebuild = 7d1014; lsrequiresiphoneos = 1; 최소 소송 = "9.0"; uidevicefamily = (1,); uilaunchImageFile = unkerImage; uilaunchImages = ({uilaunchimageminumsversion = "8.0"; uilaunchimagename = "unlainmage-800-portrait-736h"; uilaunchimageorientation = portrait; uilaunchImagesize = "{414, 736}"; Uilaunchimagename = "uilaunchimageorientation ="{414, 736} "; Portrait; UILaunchImageSize = "{375, 667}"; }, { UILaunchImageMinimumOSVersion = "7.0"; UILaunchImageName = "LaunchImage-700"; UILaunchImageOrientation = Portrait; UILaunchImageSize = "{320, 480}"; }, { UILaunchImageMinimumOSVersion = "7.0"; 초상화; uilaimagesize = "{768, 1024}"; UILAUNCHIMAGENAME = "LANKEIMAGE-700-LANDSCAPE"; uilaunchimageorientation = 풍경; uilaunchimagesize = "{768, 1024}"; }); uilaunchStoryboardName = 런치 스크린; uimainstoryboardfile = main; uirequiredDeviceCapabilities = (ARMV7); UISUpportedInterfaceorientations = (uiinterfaceorientationportrait, uiinterfaceorientationlandscapeleft, uiinterfaceorientationlandscaperight); }*/}위의 내용은 편집자가 소개 한 iOS Appicon 및 LaunchImage의 이름 (App Icon and Launch Image Name)입니다. 모든 사람에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 모든 사람에게 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!