热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

APPIcon(自留)

地址:https:developer.apple.comlibraryiosqaqa1686_index.htmlQ:Howaretheiconfilesinmyap

地址:https://developer.apple.com/library/ios/qa/qa1686/_index.html


Q:  How are the icon files in my application bundle used on iPad and iPhone?

A: Below are guidelines for handling icon files for iPhone-only apps, iPad-only apps, and universal apps.

If you don't provide artwork for one of the listed optional icons, the system will automatically scale one of your existing icon images to an appropriate size. It is strongly recommended that your application include artwork for all the icons listed, at the specific sizes needed.

Prior to iOS 3.2, icon images were required to follow a strict naming convention. These legacy names are still listed in the tables below along with example names for the more recent icons. Except for iTunesArtwork, icon images included in your app can have arbitrary names.


Note: iOS ignores the PPI (Pixels Per Inch) of icon images. You may author your icon images at any PPI but their width and height, as measured in pixels, must match the values in the tables below.



Important: iTunesArtwork icon images should be in png format, but name them without the .png extension.




Icons for iPhone-only Apps

iPhone-only applications use the following icons. Items marked with "Required" must be included.


Note: You should include images for the iPad-specific icons even if your app is not a universal app. If available, they will be used when the app is installed on an iPad.




Table 1  iPhone-only app icon requirements.

Image Size (px)

File Name

Used For

App Store

Ad Hoc

512x512

iTunesArtwork

App list in iTunes

Do not include

Optional but recommended

1024x1024

iTunesArtwork@2x

App list in iTunes on devices with retina display

Do not include

Optional but recommended

120x120

Icon-60@2x.png

Home screen on iPhone/iPod Touch with retina display

Required

Required

180x180

Icon-60@3x.png

Home screen on iPhone 6 Plus

Optional but recommended

Optional but recommended

76x76

Icon-76.png

Home screen on iPad

Optional but recommended

Optional but recommended

152x152

Icon-76@2x.png

Home screen on iPad with retina display

Optional but recommended

Optional but recommended

40x40

Icon-Small-40.png

Spotlight

Optional but recommended

Optional but recommended

80x80

Icon-Small-40@2x.png

Spotlight on devices with retina display

Optional but recommended

Optional but recommended

120x120

Icon-Small-40@3x.png

Spotlight on iPhone 6 Plus

Optional but recommended

Optional but recommended

29x29

Icon-Small.png

Settings

Recommended if you have a Settings bundle, optional otherwise

Recommended if you have a Settings bundle, optional otherwise

58x58

Icon-Small@2x.png

Settings on devices with retina display

Recommended if you have a Settings bundle, optional otherwise

Recommended if you have a Settings bundle, optional otherwise

87x87

Icon-Small@3x.png

Settings on iPhone 6 Plus

Recommended if you have a Settings bundle, optional otherwise

Recommended if you have a Settings bundle, optional otherwise


In addition to the above icons, iPhone-only applications with a deployment target of iOS 6.1 or earlier use the following icons. Items marked with "Required" must be included if the application's deployment target is iOS 6.1 or earlier.



Table 2  iPhone-only app icon requirements (iOS 6.1 and earlier).

Image Size (px)

File Name

Used For

App Store

Ad Hoc

57x57

Icon.png

Home screen on iPhone/iPod touch (iOS 6.1 and earlier)

Required

Required

114x114

Icon@2x.png

Home screen on iPhone/iPod Touch with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

72x72

Icon-72.png

Home screen on iPad (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

144x144

Icon-72@2x.png

Home screen on iPad with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

29x29

Icon-Small.png

Spotlight on iPhone/iPod Touch (iOS 6.1 and earlier) and Settings

Recommended if you have a Settings bundle, otherwise optional but recommended

Recommended if you have a Settings bundle, otherwise optional but recommended

58x58

Icon-Small@2x.png

Spotlight on iPhone/iPod Touch with retina display (iOS 6.1 and earlier) and Settings on devices with retina display

Recommended if you have a Settings bundle, otherwise optional but recommended

Recommended if you have a Settings bundle, otherwise optional but recommended

50x50

Icon-Small-50.png

Spotlight on iPad (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

100x100

Icon-Small-50@2x.png

Spotlight on iPad with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended


You can include distinct images for the iPhone and iPad icons in categories where the required sizes are equivalent, for example, Settings.


Back to Top


Icons for iPad-only Apps

iPad-only applications use the following icons. Items marked with "Required" must be included.



Table 3  iPad-only app icon requirements.

Image Size (px)

File Name

Used For

App Store

Ad Hoc

512x512

iTunesArtwork

Ad Hoc iTunes

Do not include

Optional but recommended

1024x1024

iTunesArtwork@2x

Ad Hoc iTunes on devices with retina display

Do not include

Optional but recommended

76x76

Icon-76.png

Home screen on iPad

Required

Required

152x152

Icon-76@2x.png

Home screen on iPad with retina display

Optional but recommended

Optional but recommended

40x40

Icon-Small-40.png

Spotlight on iPad

Optional but recommended

Optional but recommended

80x80

Icon-Small-40@2x.png

Spotlight on iPad with retina display

Optional but recommended

Optional but recommended

29x29

Icon-Small.png

Settings on iPad

Recommended if you have a Settings bundle, otherwise optional but recommended

Recommended if you have a Settings bundle, otherwise optional but recommended

58x58

Icon-Small@2x.png

Settings on iPad with retina display

Recommended if you have a Settings bundle, otherwise optional but recommended

Recommended if you have a Settings bundle, otherwise optional but recommended


In addition to the above icons, iPad-only applications with a deployment target of iOS 6.1 or earlier use the following icons. Items marked with "Required" must be included if the application's deployment target is iOS 6.1 or earlier.



Table 4  iPad-only app icon requirements (iOS 6.1 and earlier).

Image Size (px)

File Name

Used For

App Store

Ad Hoc

72x72

Icon-72.png

Home screen on iPad (iOS 6.1 and earlier)

Required

Required

144x144

Icon-72@2x.png

Home screen on iPad with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

50x50

Icon-Small-50.png

Spotlight on iPad (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

100x100

Icon-Small-50@2x.png

Spotlight on iPad with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended



Back to Top


Icons for Universal Apps

Universal applications use the following icons. Items marked with "Required" must be included.



Table 5  Universal app icon requirements.

Image Size (px)

File Name

Used For

App Store

Ad Hoc

512x512

iTunesArtwork

App list in iTunes

Do not include

Optional but recommended

1024x1024

iTunesArtwork@2x

App list in iTunes for devices with retina display

Do not include

Optional but recommended

120x120

Icon-60@2x.png

Home screen on iPhone/iPod Touch with retina display

Required

Required

180x180

Icon-60@3x.png

Home screen on iPhone 6 Plus

Optional but recommended

Optional but recommended

76x76

Icon-76.png

Home screen on iPad

Required

Required

152x152

Icon-76@2x.png

Home screen on iPad with retina display

Optional but recommended

Optional but recommended

40x40

Icon-Small-40.png

Spotlight

Optional but recommended

Optional but recommended

80x80

Icon-Small-40@2x.png

Spotlight on devices with retina display

Optional but recommended

Optional but recommended

120x120

Icon-Small-40@3x.png

Spotlight on iPhone 6 Plus

Optional but recommended

Optional but recommended

29x29

Icon-Small.png

Settings

Recommended if you have a Settings bundle, optional otherwise

Recommended if you have a Settings bundle, optional otherwise

58x58

Icon-Small@2x.png

Settings on devices with retina display

Recommended if you have a Settings bundle, optional otherwise

Recommended if you have a Settings bundle, optional otherwise

87x87

Icon-Small@2x.png

Settings on iPhone 6 Plus

Recommended if you have a Settings bundle, optional otherwise

Recommended if you have a Settings bundle, optional otherwise


In addition to the above icons, universal applications with a deployment target of iOS 6.1 or earlier use the following icons. Items marked with "Required" must be included if the application's deployment target is iOS 6.1 or earlier.



Table 6  Universal app icon requirements (iOS 6.1 and earlier).

Image Size (px)

File Name

Used For

App Store

Ad Hoc

57x57

Icon.png

Home screen on iPhone/iPod touch (iOS 6.1 and earlier)

Required

Required

114x114

Icon@2x.png

Home screen on iPhone/iPod Touch with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

72x72

Icon-72.png

Home screen on iPad (iOS 6.1 and earlier)

Required

Required

144x144

Icon-72@2x.png

Home screen on iPad with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

29x29

Icon-Small.png

Spotlight on iPhone/iPod Touch (iOS 6.1 and earlier) and Settings

Recommended if you have a Settings bundle, otherwise optional but recommended

Recommended if you have a Settings bundle, otherwise optional but recommended

58x58

Icon-Small@2x.png

Spotlight on iPhone/iPod Touch with retina display (iOS 6.1 and earlier) and Settings on devices with retina display

Recommended if you have a Settings bundle, otherwise optional but recommended

Recommended if you have a Settings bundle, otherwise optional but recommended

50x50

Icon-Small-50.png

Spotlight on iPad (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended

100x100

Icon-Small-50@2x.png

Spotlight on iPad with retina display (iOS 6.1 and earlier)

Optional but recommended

Optional but recommended


You can include distinct images for the iPhone and iPad icons in categories where the required sizes are equivalent, for example, Settings.


Back to Top


Adding Icons to Your App

Asset catalogs are the preferred way to manage your application's icons. New projects are configured to use asset catalogs by default. Migrating an App Icon Set or Launch Image Set in the Asset Catalog Help describes how to migrate an existing project to use asset catalogs. If your application must support iOS 4.3, or you prefer not to use asset catalogs, you can manually configure your application's icons by editing the information property list for your application. See Configuring Icons Without an Asset Catalog.



Adding Icon Images to an Asset Catalog


  1. Select the asset catalog in the project navigator. It is named Images.xcassets by default.

  2. From the left column of the editor, select the icon set. For new or migrated projects it will be named 'AppIcon'. You may need to create an icon set by clicking the (+) button in the bottom left of the editor and choosing 'New App Icon' from the context menu.


Figure 1  The AppIcon set selected in the asset catalog.

The set will only contain image wells for icons that are relevant depending upon your project's configuration at the time the asset catalog was created. If an image well is missing, expand the settings inspector and check the appropriate boxes under the App Icon pane depending upon your project's deployment target and supported devices.


Figure 2  Enable the necessary image wells under the App Icon pane of the settings inspector.

  1. Drag images from the Finder onto each image well to configure the associated icon.


Figure 3  Complete icon set for a universal app with a deployment target less than iOS 7.0

Asset catalogs create a copy of images added to them. If you had previously added the images as resources to your project you can safely remove them.


  1. Configure your app to use the new icon set.

    1. Select the name of the project in the project navigator.

    2. Select the name of your app from the list in the left column of the project editor.

    3. Select the General tab at the top of the project editor.

    4. Choose your icon set from the App Icons Source popup menu under the App Icons And Launch Images pane.


Figure 4  Configure the icon set for your app's target.


Configuring Icons Without an Asset Catalog


  1. Follow the steps in the Xcode Project Navigator Help to add each icon image to your project as a resource.

  2. Locate your application's information property list in the Xcode File Navigator. By default it will be named 

    -Info.plist, where 

     is the name of your application. Right click it and choose Open As > Source Code.

  3. The final step varies depending upon whether your app must support iOS 4.3.

If your application supports iOS 4.3 you must include the CFBundleIconFiles key to specify your application's icon images. The value for this key is an array of strings, each identifying an image in the bundle. If you have included images for the iPad-specific icons, you may either list them under the CFBundleIconFiles key, or you can list them under the device specificCFBundleIconFiles~ipad key. iPad-only applications should list their icon images under the CFBundleIconFiles key.


Listing 1  Example configuration for a universal app with deployment target of iOS 4.3.


CFBundleIconFiles

Icon-Small

Icon-Small-40

Icon-Small-50

Icon

Icon-60

Icon-72

CFBundleIconFiles~ipad

Icon-Small

Icon-Small-40

Icon-Small-50

Icon-72

Icon-76


If your application supports iOS 5.0 or above, you should include the CFBundleIcons key to specify your application's icon images. The value for this key is a dictionary with two child keys:CFBundlePrimaryIcon and UINewsstandIcon. The UINewsstandIcon key is for newsstand apps and can otherwise be omitted. The value for the CFBundlePrimaryIcon key is a dictionary that identifies the icon images associated with the app bundle. It may contain two child keys: CFBundleIconFiles and UIPrerenderedIcon. The value for the UIPrerenderedIcon key is a boolean that specifies whether your icon files already incorporates a shine effect. The value for CFBundleIconFiles key is an array of strings, each identifying an image in the bundle.


Listing 2  Example configuration for a universal app with deployment target of iOS 5.0 or greater.


CFBundleIcons

CFBundlePrimaryIcon

CFBundleIconFiles

Icon-Small

Icon-Small-40

Icon-Small-50

Icon

Icon-60

Icon-72

CFBundleIcons~ipad

CFBundlePrimaryIcon

CFBundleIconFiles

Icon-Small

Icon-Small-40

Icon-Small-50

Icon-72

Icon-76




Back to Top


Troubleshooting

This section describes common problems and how to fix them.


Note: Before attempting further troubleshooting, perform a clean build of your application (Hold down the Option key and choose Product > Clean Build Folder, then Product > Buildfrom the Xcode menu bar) and remove the app from your test device or simulator. Build your app again and attempt to reproduce the problem. You may also try clearing the contents of Xcode's derived data folder (~/Library/Developer/Xcode/DerivedData/) before building again.




My application fails to validate

There are multiple icon-related problems that will result in your application failing validation by Xcode or iTunes Connect. The underlying issue depends upon the error.



Error: Invalid Image Path

Your application's information property list references one or more icon images that were not included in the compiled bundle.

If your application is using asset catalogs to manage its icons then the information property list should not include any icon related keys; they will be added at build time by the asset catalog compiler.


  1. Open the information property list for your app's target. It can be found under the Info tab in the project editor or in the File Navigator where it will be named either 

    -Info.plist or Info.plist, where 

     is the name of your app.

  2. Remove the following keys, including device specific variations.

    • “Icon file” (CFBundleIconFile)

    • “Icon files” (CFBundleIconFiles)

    • CFBundleIcons

If your application is not using asset catalogs to manage its icons, one or more of the images listed under the CFBundleIconFiles key or the CFBundleIcons key in the information property list is not associated as a resource of your application, may not have been added to your project, or may have been accidentally removed from your project. Verify that all the images named by either of these keys is included in your project then follow the resolution steps listed under My icons don't appear on the device to verify that it is associated with your application.



Error: Missing required icon file

Your have not included artwork for one or more of the required icons, based on your app's supported devices and deployment target.

Refer to the tables above for the list of required icons. Verify that each of your icon images matches the size listed in the table.

If your application is not using asset catalogs to manage its icons, verify that all of your icon images are listed under the CFBundleIconFiles key or the CFBundleIcons key as described inConfiguring Icons Without an Asset Catalog. Remember that if you include filename extensions in the Information Property List, you must specify all image files (including the high-resolution variants) explicitly.



My icons don't appear on the device

If your project is using asset catalogs, your application may not be configured to use the correct icon set.


  1. Select the name of the project in the project navigator.

  2. Select the name of a target from the list in the left column of the project editor.

  3. Select the General tab at the top of the project editor.

  4. Verify that the name of the app icon set is selected in the Source menu under the App Icons section, as shown in Figure 5.


Figure 5  The Source menu controls which icon set is used as the app icon set.

If your project is not using asset catalogs to manage its icons, one or more of your icon images may not be associated with your app's target.


  1. Select each of your icon images in the project navigator.

  2. In the utility panel, check the box next to your app's target under the Target Membership pane as shown in Figure 6.


Figure 6  Associating an icon with a build target

Verify that your icon images use a supported color model. Images that do not use the RGB color model may appear correctly in Xcode but will fail to load on the device. If your icons include transparent areas, use your preferred graphics editing software to fill these areas with a solid color.

Some graphics software may produce images which load correctly in Xcode but fail to load on the device, resulting in a blank icon. Try exporting your icon images with a different graphics editor such as the built in Preview app.



A previous version of my icon appears on the device

Your testing device or simulator may have a partially outdated build. That is, Xcode failed to copy a modified resource to the app bundle it installed on the device as part of the build & run process. To force Xcode to copy the most recent resources from your project directory:


  1. Remove the app from your testing device or simulator.

  2. Clean the build directory. Hold down the Option key and choose Product > Clean Build Folder, then Product > Build from the Xcode menu bar

  3. Build and run your app.

If your project is using asset catalogs then you must replace the modified image in the asset catalog. Asset catalogs do not track files on disk, opting instead to make a copy of the image at the time it is added to the asset catalog.



My icon has a black background in the App Store

The Large App Icon you uploaded to iTunes Connect includes transparent areas. The iTunes Connect Developer Guide lists the complete requirements for the Large App Icon, including that it must be opaque.

You can use the Preview app to check your image for transparent areas, which will appear dark grey as shown in Figure 7. Use your preferred graphics editing software to fill in the transparent areas with the desired background color.


Figure 7  Preview's dark grey canvas background is visible through transparent areas in an image.


The wrong icon appears in the App Store

Your application bundle includes additional images which are being detected as valid icon images.


Note: Different icon images from the application's bundle, and the large app icon, are displayed in various contexts within the App Store. For example, the incorrect icon image may appear in the search results but not on your application's landing page.


You may encounter this issue if your icon images deviate from the naming convention shown in the above tables. If your application bundle also contains once or more images that match the naming convention in the tables above, these images may be detected as valid icon images by the App Store. This may occur regardless of whether those images are included in the asset catalog or are referenced by the application's Information Property List. The solution is to rename or remove the images.

You may encounter this issue when building an app using a third party development environment or if your project was created using a template project provided by a third party. Both will usually include a default set of icon images. If you fail to remove these images or replace all of them with your own artwork, the App Store may display them in the search results for your app. Like the iOS home screen, the icons displayed in the search results depend upon the current device. It is possible that the incorrect icon is shown in the search results on certain devices but not others.

The solution is to delete any instances of the template-provided icons that remain in your project and remove any references to the deleted files from the information property list. Due to the wide variety of ways in which iOS versions have allowed developers to specify app icons in the Information Property List, you may find it simpler and less error prone to remove all icon related keys from the Information Property List and then reconfigure your app's icons using the steps presented in Adding Icons to Your App. See Start Over.



Start Over

If the none of the above solutions resolve the problem, follow the steps below to remove all the icons and icon related configuration from your app. Then follow the steps in Adding Icons to Your App to re-configure the proper icons for your app.


Warning: Make sure you have a backup of your icon artwork at a location outside of your project directory.




Remove the Icon Set From Your Asset Catalog


  1. Select the asset catalog in the project navigator. It is named Images.xcassets by default.

  2. In the left column of the editor, control click the icon set and choose Remove Selected Items from the context menu. By default the icon set will be named 'AppIcon'.



Remove Icon Images From Your Project

Using the Xcode file navigator, remove any icon images from your project your had previously added to your project as resources. Icon images usually have a file name beginning with 'Icon' or 'AppIcon'.



Remove Icon Related Keys From The Information Property List


  1. Open the Information Property List for your application. It can be found under the Info tab in the project editor or in the navigator where it will be named either YourApp-Info.plist orInfo.plist.

  2. Remove the following keys, including device specific variations.

    • “Icon file” (CFBundleIconFile)

    • “Icon files” (CFBundleIconFiles)

    • CFBundleIcons



Clean The Project

To remove any cached icons, clean your target. Choose Product > Clean from the menu bar.

Finally, follow the steps in Adding Icons to Your App to re-configure the proper icons for your app.


Back to Top


Additional Resources

For additional information, see the App Icons section in the iOS App Programming Guide.

For information about designing your application's icons, see the App Icon section of the iOS Human Interface Guidelines.

For an example project with properly configured icons, see the Application Icons and Launch Images for iOS sample code.


Back to Top






Document Revision History




Date Notes
2014-12-01

Added iPhone 6 Plus icons. Further expanded the troubleshooting section.

 

Added iPhone 6 Plus icons. Further expanded the troubleshooting section.

 

Added iPhone 6 Plus icons. Further expanded the troubleshooting section.

2014-05-19

Added troubleshooting steps for incorrect icons appearing in the App Store search results.

2014-02-03

Updated for Xcode 5 and iOS 7.

2013-07-18

Added icon information for iPad with retina display.

2011-07-14

After iOS 4.3, order doesn't matter in the icon arrangement. Added links to related references.

2010-07-14

Fixed outdated "Add Icon files in Info.plist" section.

2010-07-12

Updated for iOS 4 requirements.

2010-04-09

New document that explains how the icon files in an application bundle are used on iPad and iPhone.












Feedback


推荐阅读
  • 2018年9月21日,Destoon官方发布了安全更新,修复了一个由用户“索马里的海贼”报告的前端GETShell漏洞。该漏洞存在于20180827版本的某CMS中,攻击者可以通过构造特定的HTTP请求,利用该漏洞在服务器上执行任意代码,从而获得对系统的控制权。此次更新建议所有用户尽快升级至最新版本,以确保系统的安全性。 ... [详细]
  • 浏览器作为我们日常不可或缺的软件工具,其背后的运作机制却鲜为人知。本文将深入探讨浏览器内核及其版本的演变历程,帮助读者更好地理解这一关键技术组件,揭示其内部运作的奥秘。 ... [详细]
  • 本文介绍了UUID(通用唯一标识符)的概念及其在JavaScript中生成Java兼容UUID的代码实现与优化技巧。UUID是一个128位的唯一标识符,广泛应用于分布式系统中以确保唯一性。文章详细探讨了如何利用JavaScript生成符合Java标准的UUID,并提供了多种优化方法,以提高生成效率和兼容性。 ... [详细]
  • XAMPP 遇到 404 错误:无法找到请求的对象
    在使用 XAMPP 时遇到 404 错误,表示请求的对象未找到。通过详细分析发现,该问题可能由以下原因引起:1. `httpd-vhosts.conf` 文件中的配置路径错误;2. `public` 目录下缺少 `.htaccess` 文件。建议检查并修正这些配置,以确保服务器能够正确识别和访问所需的文件路径。 ... [详细]
  • 在《Cocos2d-x学习笔记:基础概念解析与内存管理机制深入探讨》中,详细介绍了Cocos2d-x的基础概念,并深入分析了其内存管理机制。特别是针对Boost库引入的智能指针管理方法进行了详细的讲解,例如在处理鱼的运动过程中,可以通过编写自定义函数来动态计算角度变化,利用CallFunc回调机制实现高效的游戏逻辑控制。此外,文章还探讨了如何通过智能指针优化资源管理和避免内存泄漏,为开发者提供了实用的编程技巧和最佳实践。 ... [详细]
  • 基于Net Core 3.0与Web API的前后端分离开发:Vue.js在前端的应用
    本文介绍了如何使用Net Core 3.0和Web API进行前后端分离开发,并重点探讨了Vue.js在前端的应用。后端采用MySQL数据库和EF Core框架进行数据操作,开发环境为Windows 10和Visual Studio 2019,MySQL服务器版本为8.0.16。文章详细描述了API项目的创建过程、启动步骤以及必要的插件安装,为开发者提供了一套完整的开发指南。 ... [详细]
  • 在C#编程中,数值结果的格式化展示是提高代码可读性和用户体验的重要手段。本文探讨了多种格式化方法和技巧,如使用格式说明符、自定义格式字符串等,以实现对数值结果的精确控制。通过实例演示,展示了如何灵活运用这些技术来满足不同的展示需求。 ... [详细]
  • 如何使用 `org.eclipse.rdf4j.query.impl.MapBindingSet.getValue()` 方法及其代码示例详解 ... [详细]
  • Spring框架中枚举参数的正确使用方法与技巧
    本文详细阐述了在Spring Boot框架中正确使用枚举参数的方法与技巧,旨在帮助开发者更高效地掌握和应用枚举类型的数据传递,适合对Spring Boot感兴趣的读者深入学习。 ... [详细]
  • 当使用 `new` 表达式(即通过 `new` 动态创建对象)时,会发生两件事:首先,内存被分配用于存储新对象;其次,该对象的构造函数被调用以初始化对象。为了确保资源管理的一致性和避免内存泄漏,建议在使用 `new` 和 `delete` 时保持形式一致。例如,如果使用 `new[]` 分配数组,则应使用 `delete[]` 来释放内存;同样,如果使用 `new` 分配单个对象,则应使用 `delete` 来释放内存。这种一致性有助于防止常见的编程错误,提高代码的健壮性和可维护性。 ... [详细]
  • 本文详细介绍了一种利用 ESP8266 01S 模块构建 Web 服务器的成功实践方案。通过具体的代码示例和详细的步骤说明,帮助读者快速掌握该模块的使用方法。在疫情期间,作者重新审视并研究了这一未被充分利用的模块,最终成功实现了 Web 服务器的功能。本文不仅提供了完整的代码实现,还涵盖了调试过程中遇到的常见问题及其解决方法,为初学者提供了宝贵的参考。 ... [详细]
  • 技术日志:使用 Ruby 爬虫抓取拉勾网职位数据并生成词云分析报告
    技术日志:使用 Ruby 爬虫抓取拉勾网职位数据并生成词云分析报告 ... [详细]
  • Vue应用预渲染技术详解与实践 ... [详细]
  • 本文探讨了 Kafka 集群的高效部署与优化策略。首先介绍了 Kafka 的下载与安装步骤,包括从官方网站获取最新版本的压缩包并进行解压。随后详细讨论了集群配置的最佳实践,涵盖节点选择、网络优化和性能调优等方面,旨在提升系统的稳定性和处理能力。此外,还提供了常见的故障排查方法和监控方案,帮助运维人员更好地管理和维护 Kafka 集群。 ... [详细]
  • 在Ubuntu系统中配置Python环境变量是确保项目顺利运行的关键步骤。本文介绍了如何将Windows上的Django项目迁移到Ubuntu,并解决因虚拟环境导致的模块缺失问题。通过详细的操作指南,帮助读者正确配置虚拟环境,确保所有第三方库都能被正确识别和使用。此外,还提供了一些实用的技巧,如如何检查环境变量配置是否正确,以及如何在多个虚拟环境之间切换。 ... [详细]
author-avatar
于磊com
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有