The old project is compatible with iOS 6 and iPhone 5

Source: Internet
Author: User

Every time Apple releases a system, developers are busy working for a while, updating xcode to adapt to the new system: for example, ios4 supports the graph that retina needs @ 2x; for example, ios5 does not support udid; for example, iOS 6 and iPhone 5 face the following problems.

1. Add retina 4 launch image, and you will be prompted when running the project.

Click Add directly at this time. A default-568h@2x.png black image will be created:

If this parameter is not added, the program runs normally.

Effect after adding

In this case, I would like to say that when the first time transparency says that we want to add such a picture to the group, my first response is: Isn't there a black picture when the program starts? However, my program does not need to start the graph. This worry is unnecessary only when you add this image. It is estimated that Apple has made some optimizations. when it determines that the image is a black image, it will be skipped directly.

2. Group Table view background color is deprecated in IOS 6.0


When using the background color, the color that comes with my favorite system is: "group table view background color ". Now that the color is gone, you can change it to another color.

3. About multiple targets

Drag the volume file to the corresponding "Copy bundle resources.

Note that when multiple targets are running on the simulator, they are not as convenient as they were before. You can directly switch the configuration file to run them. When testing different target representations, in addition to switching the configuration file, you also need to clear the simulator ~

4. xcode4.5 no longer supports armv6, that is, systems below ios4.3.3.

Unsupported hardware devices include: IPOD 2nd Gen, iPhone 3G or older iPhone
For example, the error message during packaging is:

1
2
Warning: IOS deployment targets lower than 4.3 are not supported (current iphoneos_deployment_target = "4.0", archs = "armv7 ").
(Null): iPhone/iPod Touch: application executable is missing a required architecture. At least one of the following Architecture (s) must be present: armv6 (-19033)

Because I like to use block, I developed Dongdong, which generally supports ios4.0 at the lowest level. It seems that Apple is forcing developers and users to upgrade.

5. Provide a piece of code to judge the iPhone
1 # Define iphone5 ([uiscreen instancesrespondtoselector: @ selector (currentmode)]? Cgsizeequaltosize (cgsizemake (640,113 6), [[uiscreen mainscreen] currentmode]. Size): No)

Direct use

1 If (iphone5) ooxx

You can.
In addition, if the code is written to the interface, the view height in iPhone 5 is 568 ~

6. Questions about XIB adaptive

By default, if your interface contains scrollview/tableview, this interface basically does not need to be changed because the middle branch is automatically stretched. If these two full-screen controls are not included, you may need to add another XIB for iPhone 5. The method is simple. Create an XIB file and set the View Size to retina 4 full screen. I have already mentioned how to judge iPhone 5 and how to read different XIB files without using code?

7. About screen Rotation

(There was a problem with ios5, but this time again)
To thoroughly understand this problem, you also need to do some experiments yourself. ios6 canceled an API and added two APIs, but this one cannot meet my needs: the application is a portrait screen on all interfaces and only a landscape screen on one screen. It takes me half a day to complete this situation. Let's just talk about how to implement it.
First, the view in the XIB of the horizontal screen is horizontal.
Second, screen adaptation only supports landscape screens

1
2
3
-(Bool) shouldautorotatetointerfaceorientation :( uiinterfaceorientation) interfaceorientation {
Return uiinterfaceorientationislandscape (interfaceorientation );
}

Third: The view is present.
Fourth: Hide the status bar in viewdidload

1
2
3
4
5
6
-(Void) viewdidload {
If (iossystemversion> = 5.0 ){
// 5.0 and later, if this is not completed, and the interface is misplaced and the animation is taken, it is easy to see a white head
[[Uiapplication sharedapplication] setstatusbarhidden: Yes];
}
}

Fifth, viewwillappear rotates the view 90 degrees.

1
2
3
4
5
6
7
8
9
10
11
12
13
-(Void) viewwillappear :( bool) animated {
[Super viewwillappear: animated];
[Uiview animatewithduration: 0.0f
Animations: ^ {
[Self. View settransform: cgaffinetransformmakerotation (m_pi/2)];
If (iphone5 ){
Self. View. Frame = cgrectmake (0, 0,568,320 );
}
Else {
Self. View. Frame = cgrectmake (0, 0,480,320 );
}
}];
}

8. Third-party Libraries

If a third-party library is used in the project, the following problems will be prompted during packaging:

1
2
Ld: file is universal (3 slices) but does not contain a (n) armv7s slice:/users/Rainbird/desktop/MyApp/ifilemanager/zbarsdk/libzbar. a For architecture armv7s
Clang: Error: Linker command failed with exit code 1 (use-V to see Invocation)

The above prompt is that the library libzbar I use does not support armv7s.

For third-party libraries, if they are closed-source, such as advertisement sdks and the sdks provided by the partners, they can only wait. When will the users update the sdks. Like the zbarsdk I met, don't wait for any third-party open-source sdks. Let's just try it yourself.

First, a temporary solution for closing the source database is to cancel the support for armv7s so that you can start testing without waiting for a third-party database. The solution is as follows: in xcode, click the target, click build settings, find valid_archs, and delete arvm7s.

The above is only a temporary solution. Let's take zbar compilation as an example:

  • 1. Go to the zbar homepage and download the source code package.
  • 2. decompress the package, go to the iPhone folder, delete examples, and double-click zbar. xcodeproj to run the project.
  • 3. Command + B compile the project (of course, this step will remind you to update setting. It is recommended to run the project after the update ).

4. Right-click lib and find it in the directory.

The story should have ended here, but the file found above can only be used in real machines and cannot be used in simulators. What should I do?

Go to the build directory of the tool and you will see the following directories:
Debug-iphoneos/debug-iphonesimulator/release-iphoneos/release-iphonesimulator/

Combine the package of the simulator with the package of the real machine.

1
2
3
[Rainbird @ localhost products] $ pwd
/Users/Rainbird/library/developer/xcode/deriveddata/zbar-athgobfbdtwgftgcogpuwegpawlj/build/products
[Rainbird @ localhost products] $ lipo-create release-iphoneos/libzbar. A release-iphonesimulator/libzbar. A-O libzbar.

Explain the commands to merge two libraries in Lipo: the first package in Lipo-create, the second package in Lipo-create, and the packages after the merger in the second package.

In this way, the libzbar. A can be used in both the simulator and the real machine. Here is an episode. If the static library is compiled once, all the packages will be generated, and the package on the real machine will be used as soon as it comes up, and it will not be used on the simulator, I searched for a long time at the location of the real machine and thought that the simulator package could not be generated.

Another common command for lipo is to view the package information-Info parameter.

1
2
[Rainbird @ localhost products] $ lipo-Info libzbar.
Ubuntures In the FAT file: libzbar. A are: armv7 (cputype (12) cpusubtype (11) i386

Reprinted, please note: dapps developers» old projects adapt to iOS 6 and iPhone 5 stories

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.