Old projects adapt to iOS 6 and iPhone 5

Source: Internet
Author: User
ArticleDirectory
    • 1. Add retina 4 launch image, and you will be prompted when running the project.
    • 2. Group Table view background color is deprecated in IOS 6.0
    • 3. About multiple targets
    • 4. xcode4.5 no longer supports armv6, that is, systems below ios4.3.3.
    • 5. Provide a piece of code to judge the iPhone
    • 6. Questions about XIB adaptive
    • 7. About screen Rotation

From: http://www.dapps.net/dev/iphone/old-project-ios-6-iphone-5-1.html

 

 

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 no value is added,ProgramWhen running, there will be black borders.

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, one of my favorite system colors is: "group table view background
Color ". Now that the color is gone, you can change it to another color.

3. About multiple targets

Upload File, drag it 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 iPhone judgment Code
1 # Define iphone5 ([uiscreen
Instancesrespondtoselector: @ selector (currentmode)]?
Cgsizeequaltosize (cgsizemake (640,113 6), [uiscreen mainscreen]
Currentmode]. Size): No)

Direct use

1 If (IPhone 5)
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 size of the view 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 this 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 or later, if this is not completed, the interface is misplaced.
The animation 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 ( IPhone 5 )
{
Self. View. Frame
= Cgrectmake ( 0 , 0 , 568 , 320 ) ;

}

Else {
Self. View. Frame = Cgrectmake ( 0 , 0 , 480 , 320 ) ;

}
} ] ;
}
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.